Per #2707, when an open file is moved into a different directory over
NFS, it may leave a .nfsXXX hardlink behind. This causes the rmdir in
safe_open to fail, leaving tempdir droppings around. This patch works
around the problem by closing the file after creating it and reopening
it after rename.
rmdir (safe_dir);
return fd;
}
-
+
+ /* NFS and I believe cygwin do not handle movement of open files well */
+ close (fd);
if (mutt_put_file_in_place (path, safe_file, safe_dir) == -1)
- {
- close (fd);
return -1;
- }
- }
- else
- {
- if ((fd = open (path, flags, 0600)) < 0)
- return fd;
}
+
+ if ((fd = open (path, flags & ~O_EXCL, 0600)) < 0)
+ return fd;
/* make sure the file is not symlink */
if (lstat (path, &osb) < 0 || fstat (fd, &nsb) < 0 ||