svn commit: r231087 - head/lib/libutil

Pawel Jakub Dawidek pjd at
Mon Feb 6 14:25:17 UTC 2012

On Mon, Feb 06, 2012 at 02:11:24PM +0000, Guy Helmer wrote:
> Author: ghelmer
> Date: Mon Feb  6 14:11:24 2012
> New Revision: 231087
> URL:
> Log:
>   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 10
>   ref8-amd64:/home/trociny% daemon -p /tmp/ sleep 10
>   daemon: process already running, pid: 19799
>   kopusha:~% uname -r
>   10.0-CURRENT
>   kopusha:~% daemon -p /tmp/ sleep 10
>   kopusha:~% daemon -p /tmp/ sleep 10
>   kopusha:~%

Not sure if you saw the following discussion, but O_CLOEXEC is ok here.
Mikolaj is working on improving daemon to handle it properly.

What we had in 8.2-STABLE is also incorrect, but for other reasons.

All in all, O_CLOEXEC should stay. What Mikolaj presented is a problem
in daemon(8) and not pidfile(3).

Pawel Jakub Dawidek             
FreeBSD committer               
Am I Evil? Yes, I Am!           
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url :

More information about the svn-src-head mailing list