Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Feb 2012 10:25:42 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        Pawel Jakub Dawidek <pjd@freebsd.org>
Cc:        src-committers@freebsd.org, Guy Helmer <ghelmer@palisadesystems.com>, svn-src-all@freebsd.org, Andrey Zonov <andrey@zonov.org>, Mikolaj Golub <trociny@freebsd.org>, svn-src-head@freebsd.org
Subject:   Re: svn commit: r230869 - head/usr.sbin/daemon
Message-ID:  <201202061025.42239.jhb@freebsd.org>
In-Reply-To: <20120206144337.GH1324@garage.freebsd.pl>
References:  <201202011641.q11Gf0j6095461@svn.freebsd.org> <1E1FA19C-7C4C-4288-B163-E33FC68D9837@palisadesystems.com> <20120206144337.GH1324@garage.freebsd.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday, February 06, 2012 9:43:39 am Pawel Jakub Dawidek wrote:
> On Mon, Feb 06, 2012 at 08:31:47AM -0600, Guy Helmer wrote:
> > If my understanding of flock(2) semantics is correct, with open(2) 
O_CLOEXEC or fcntl(2) FD_CLOEXEC set on the pidfile, the closing of the 
pidfile file descriptor during an exec will result in loss of the lock on the 
pidfile regardless of whether daemon(8) hangs around to wait for the child 
exit.
> 
> My expectation is that as long as parent process holds pidfile
> descriptor open and locked, the pidfile should remain locked even after
> fork(2)/execve(2). Worth checking, though.

Yes, if the daemon process hung around that would work.  Note that I think
you would need to do a double-fork for that to work though since users
expect daemon to return instantly and not need to be put in the background.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202061025.42239.jhb>