From owner-freebsd-current@FreeBSD.ORG Thu Oct 13 11:47:08 2011 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E0B810656FA for ; Thu, 13 Oct 2011 11:47:08 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.dawidek.net (60.wheelsystems.com [83.12.187.60]) by mx1.freebsd.org (Postfix) with ESMTP id 639C28FC13 for ; Thu, 13 Oct 2011 11:47:07 +0000 (UTC) Received: from localhost (58.wheelsystems.com [83.12.187.58]) by mail.dawidek.net (Postfix) with ESMTPSA id B174BCE7; Thu, 13 Oct 2011 13:31:08 +0200 (CEST) Date: Thu, 13 Oct 2011 13:30:26 +0200 From: Pawel Jakub Dawidek To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= Message-ID: <20111013113024.GE1667@garage.freebsd.pl> References: <86pqi1b1qp.fsf@ds4.des.no> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="m1UC1K4AOz1Ywdkx" Content-Disposition: inline In-Reply-To: <86pqi1b1qp.fsf@ds4.des.no> X-OS: FreeBSD 9.0-CURRENT amd64 User-Agent: Mutt/1.5.21 (2010-09-15) Cc: current@freebsd.org Subject: Re: incorrect use of pidfile(3) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2011 11:47:08 -0000 --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--