summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorghelmer <ghelmer@FreeBSD.org>2012-02-06 14:11:24 +0000
committerghelmer <ghelmer@FreeBSD.org>2012-02-06 14:11:24 +0000
commit10fb6673e8872813e1d696e3dd3c20ec7b5e1933 (patch)
tree36403f044c4b168dc5d5da5990fda2191ed40ee5 /lib
parent9df8133640c5924838c6b7491804ea0842d4d4c4 (diff)
downloadFreeBSD-src-10fb6673e8872813e1d696e3dd3c20ec7b5e1933.zip
FreeBSD-src-10fb6673e8872813e1d696e3dd3c20ec7b5e1933.tar.gz
Using the O_CLOEXEC flag on open(2) caused the pidfile lock to be lost
when the child process execs daemon's target program thanks to flock(2) semantics. So, we apparently have to leak the open pidfile's file descriptor to keep the lock for the pidfile(3) functions to work properly. Test case demonstrated by trociny: ref8-amd64:/home/trociny% uname -r 8.2-STABLE ref8-amd64:/home/trociny% daemon -p /tmp/sleep.pid sleep 10 ref8-amd64:/home/trociny% daemon -p /tmp/sleep.pid sleep 10 daemon: process already running, pid: 19799 kopusha:~% uname -r 10.0-CURRENT kopusha:~% daemon -p /tmp/sleep.pid sleep 10 kopusha:~% daemon -p /tmp/sleep.pid sleep 10 kopusha:~%
Diffstat (limited to 'lib')
-rw-r--r--lib/libutil/pidfile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libutil/pidfile.c b/lib/libutil/pidfile.c
index bca0315..55e3e0f 100644
--- a/lib/libutil/pidfile.c
+++ b/lib/libutil/pidfile.c
@@ -124,7 +124,7 @@ pidfile_open(const char *path, mode_t mode, pid_t *pidptr)
* pidfile_write() can be called multiple times.
*/
fd = flopen(pfh->pf_path,
- O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NONBLOCK, mode);
+ O_WRONLY | O_CREAT | O_TRUNC | O_NONBLOCK, mode);
if (fd == -1) {
if (errno == EWOULDBLOCK && pidptr != NULL) {
count = 20;
OpenPOWER on IntegriCloud