incorrect use of pidfile(3)

看板FB_current作者時間14年前 (2011/10/13 19:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/10 (看更多)
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: 1) common case process A process B main() pidfile_open() -> success perform_initialization() daemon() pidfile_write() -> success perform_work() main() pidfile_open() -> EEXIST exit() 2) very unlikely but still possible case process A process B main() pidfile_open() -> success main() perform_initialization() pidfile_open() -> EAGAIN daemon() perform_initialization() pidfile_write() -> success daemon() perform_work() perform_work() The problem is that most of them (at least the ones I checked) ignore a pidfile_open() failure unless errno =3D=3D EEXIST. 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? DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
文章代碼(AID): #1EbiJkHm (FB_current)
討論串 (同標題文章)
文章代碼(AID): #1EbiJkHm (FB_current)