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
pgpVDMdtEPP28.pgp
Description: PGP signature