Re: incorrect use of pidfile(3)

看板FB_current作者時間14年前 (2011/10/13 20:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/10 (看更多)
--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--
文章代碼(AID): #1EbjB_sE (FB_current)
討論串 (同標題文章)
文章代碼(AID): #1EbjB_sE (FB_current)