svn commit: r231087 - head/lib/libutil

Pawel Jakub Dawidek pjd at FreeBSD.org
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: http://svn.freebsd.org/changeset/base/231087
> 
> 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.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:~%

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                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://tupytaj.pl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-all/attachments/20120206/e358a16d/attachment.pgp


More information about the svn-src-all mailing list