summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-08-27 13:59:06 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-08-27 13:59:06 +0200
commit0bbe2e436fc51df3091e28464dfac2f6d3bf5f38 (patch)
tree56c7a3fb418138ea07c9f25c68f0b52a8bc7b28b
parentbe322c569708ed17cc53c068d89d3bb755cb354f (diff)
downloadnq-0bbe2e436fc51df3091e28464dfac2f6d3bf5f38.tar.gz
nq-0bbe2e436fc51df3091e28464dfac2f6d3bf5f38.tar.xz
nq-0bbe2e436fc51df3091e28464dfac2f6d3bf5f38.zip
nq: fsync after rename
For details, see
https://groups.google.com/forum/#!topic/comp.unix.programmer/AM2V83RCOVE
-rw-r--r--nq.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/nq.c b/nq.c
index 9b8b692..6fe739c 100644
--- a/nq.c
+++ b/nq.c
@@ -209,6 +209,9 @@ usage:
 	/* drop leading '.' */
 	renameat(dirfd, lockfile, dirfd, lockfile+1);
 
+	/* block until rename is committed */
+	fsync(dirfd);
+
 	write_execline(lockfd, argc, argv);
 
 	dup2(lockfd, 2);