Re: incorrect use of pidfile(3)

2011-10-14 Thread Pawel Jakub Dawidek
On Thu, Oct 13, 2011 at 04:11:40PM +0200, Dag-Erling Smørgrav wrote: Pawel Jakub Dawidek p...@freebsd.org writes: I'm still in opinion that EWOULDBLOCK and EAGAIN (which is the same value on FreeBSD) should be converted to EEXIST on pidfile_open() return. The historical (and documented)

Re: incorrect use of pidfile(3)

2011-10-14 Thread Dag-Erling Smørgrav
Pawel Jakub Dawidek p...@freebsd.org writes: After proposed changes it would look like this, what do you think? http://people.freebsd.org/~pjd/patches/pidfile.3.patch Looks OK to me, but you should also remove the paragraph about EAGAIN in the man page. DES -- Dag-Erling Smørgrav -

incorrect use of pidfile(3)

2011-10-13 Thread Dag-Erling Smørgrav
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()

Re: incorrect use of pidfile(3)

2011-10-13 Thread Pawel Jakub Dawidek
On Thu, Oct 13, 2011 at 12:54:38PM +0200, Dag-Erling Smørgrav 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: 1) common case process A process B main()

Re: incorrect use of pidfile(3)

2011-10-13 Thread Dag-Erling Smørgrav
Pawel Jakub Dawidek p...@freebsd.org writes: Dag-Erling Smørgrav d...@des.no writes: How do we fix this? My suggestion is to loop until pidfile_open() succeeds or errno != EAGAIN. Does anyone have any objections to that approach? I think we already do that internally in pidfile_open().

Re: incorrect use of pidfile(3)

2011-10-13 Thread Carlos A. M. dos Santos
2011/10/13 Dag-Erling Smørgrav d...@des.no: Pawel Jakub Dawidek p...@freebsd.org writes: Dag-Erling Smørgrav d...@des.no writes: How do we fix this?  My suggestion is to loop until pidfile_open() succeeds or errno != EAGAIN.  Does anyone have any objections to that approach? I think we

Re: incorrect use of pidfile(3)

2011-10-13 Thread Dag-Erling Smørgrav
After discussing this with pjd@ on IRC, I arrived at the attached patch, which increases the length of time pidfile_open() itself waits (I hadn't noticed that it already looped) and sets *pidptr to -1 if it fails to read a pid. DES -- Dag-Erling Smørgrav - d...@des.no Index:

Re: incorrect use of pidfile(3)

2011-10-13 Thread Pawel Jakub Dawidek
On Thu, Oct 13, 2011 at 02:54:16PM +0200, Dag-Erling Smørgrav wrote: After discussing this with pjd@ on IRC, I arrived at the attached patch, which increases the length of time pidfile_open() itself waits (I hadn't noticed that it already looped) and sets *pidptr to -1 if it fails to read a

Re: incorrect use of pidfile(3)

2011-10-13 Thread Dag-Erling Smørgrav
Pawel Jakub Dawidek p...@freebsd.org writes: I'm still in opinion that EWOULDBLOCK and EAGAIN (which is the same value on FreeBSD) should be converted to EEXIST on pidfile_open() return. The historical (and documented) behavior is to return EAGAIN. Also if we now have for loop, why not to

Re: incorrect use of pidfile(3)

2011-10-13 Thread Jos Backus
Why not import daemontools? It's public domain these days. Pidfiles are a hacky mess. UNIX already has a way to track processes which avoids all these issues, with very little overhead. Jos ___ freebsd-current@freebsd.org mailing list