Date: Thu, 13 Oct 2011 13:30:26 +0200 From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= <des@des.no> Cc: current@freebsd.org Subject: Re: incorrect use of pidfile(3) Message-ID: <20111013113024.GE1667@garage.freebsd.pl> In-Reply-To: <86pqi1b1qp.fsf@ds4.des.no> References: <86pqi1b1qp.fsf@ds4.des.no>
next in thread | previous in thread | raw e-mail | index | archive | help
--m1UC1K4AOz1Ywdkx Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 13, 2011 at 12:54:38PM +0200, Dag-Erling Sm=F8rgrav wrote: > I looked at some of the programs that use pidfile(3) in base, and they > pretty much all get it wrong. Consider these two scenarios: >=20 > 1) common case >=20 > process A process B >=20 > main() > pidfile_open() -> success > perform_initialization() > daemon() > pidfile_write() -> success > perform_work() main() > pidfile_open() -> EEXIST > exit() >=20 > 2) very unlikely but still possible case >=20 > process A process B >=20 > main() > pidfile_open() -> success main() > perform_initialization() pidfile_open() -> EAGAIN > daemon() perform_initialization() > pidfile_write() -> success daemon() > perform_work() perform_work() >=20 > The problem is that most of them (at least the ones I checked) ignore a > pidfile_open() failure unless errno =3D=3D EEXIST. >=20 > How do we fix this? My suggestion is to loop until pidfile_open() > succeeds or errno !=3D EAGAIN. Does anyone have any objections to that > approach? I think we already do that internally in pidfile_open(). Can you take a loo= k at the source and confirm that this is what you mean? --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com --m1UC1K4AOz1Ywdkx Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk6Wy88ACgkQForvXbEpPzTV6QCcDsNDZ/F72yizM78kgw6bMZhe FZwAoO8jFCQRyzPTFOsviAf9ofh4bHkj =dbic -----END PGP SIGNATURE----- --m1UC1K4AOz1Ywdkx--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111013113024.GE1667>