[Toybox] Small fix for xpidfile()

Rob Landley rob at landley.net
Fri Sep 6 02:46:21 PDT 2013


On 09/01/2013 08:16:44 AM, Felix Janda wrote:
> # HG changeset patch
> # User Felix Janda <felix.janda at posteo.de>
> # Date 1378041238 -7200
> # Node ID 587b7572aac2a64988503458155e1f2546672525
> # Parent  3cd61d16aabec82505da96a142663cedbba8d12a
> fix for xpidfile()
> 
> diff -r 3cd61d16aabe -r 587b7572aac2 lib/xwrap.c
> --- a/lib/xwrap.c	Sat Aug 31 12:30:41 2013 +0200
> +++ b/lib/xwrap.c	Sun Sep 01 15:13:58 2013 +0200
> @@ -463,7 +463,7 @@
>      spid[xread(fd, spid, sizeof(spid)-1)] = 0;
>      close(fd);
>      pid = atoi(spid);
> -    if (pid < 1 || kill(pid, 0) == ESRCH) unlink(pidfile);
> +    if (pid < 1 || (kill(pid, 0) == -1 && errno == ESRCH))  
> unlink(pidfile);

Heh. Good catch.

(Applied a slightly different fix because comparing == -1 isn't  
necessary, just kill returns nonzero. Saves an instruction or two.)

Rob

 1378460781.0


More information about the Toybox mailing list