pidfile_open incorrectly returns EAGAIN when pidfile is locked
Pawel Jakub Dawidek
pjd at FreeBSD.org
Thu Mar 14 16:28:26 UTC 2013
On Thu, Mar 14, 2013 at 09:42:40AM -0400, John Baldwin wrote:
> On Thursday, March 14, 2013 4:44:20 am Pawel Jakub Dawidek wrote:
> > On Thu, Mar 14, 2013 at 08:28:25AM +0100, Dirk Engling wrote:
> > > -----BEGIN PGP SIGNED MESSAGE-----
> > > Hash: SHA1
> > >
> > > On 13.03.13 23:08, Pawel Jakub Dawidek wrote:
> > >
> > > > I think I considered something similar at first, but the change I
> > > > proposed was optimal, IMHO at the cost of producing pretty large
> > > > diff, because of indentation change. But to be sure, can you send a
> > > > patch of your proposed change?
> > >
> > > http://erdgeist.org/arts/software/Code/pidfile.c.diff
> >
> > Right. Your patch assumes EWOULDBLOCK is equal to EAGAIN, which is true
> > on FreeBSD, but is not portable. Also in case pidptr is NULL you compare
> > errno three times instead of just one (not a big deal of course, just
> > something that could be done a bit more optimal:)).
>
> Geeze, why not just add an else. That's the really short diff:
Heh, I did consider that as well, but here you check errno twice,
instead of once. Guys, is there anything wrong with the patch I
proposed?
> Index: pidfile.c
> ===================================================================
> --- pidfile.c (revision 248162)
> +++ pidfile.c (working copy)
> @@ -140,7 +140,8 @@ pidfile_open(const char *path, mode_t mode, pid_t
> *pidptr = -1;
> if (errno == 0 || errno == EAGAIN)
> errno = EEXIST;
> - }
> + } else if (errno == EWOULDBLOCK)
> + errno = EEXIST;
> free(pfh);
> return (NULL);
> }
--
Pawel Jakub Dawidek http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://tupytaj.pl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20130314/1b7c0ef9/attachment.sig>
More information about the freebsd-current
mailing list