diff options
author | Leah Neukirchen <leah@vuxu.org> | 2018-09-17 13:01:11 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2018-09-17 13:01:11 +0200 |
commit | b92fba5ca891fa6a1f4f3a6f12789b87ccc1b484 (patch) | |
tree | aa0a30772828dd144744ae6df37aa7950f164547 /pwait.c | |
parent | 86e7c446c64441e3d6831bd4d400c99525b9c9f6 (diff) | |
download | extrace-b92fba5ca891fa6a1f4f3a6f12789b87ccc1b484.tar.gz extrace-b92fba5ca891fa6a1f4f3a6f12789b87ccc1b484.tar.xz extrace-b92fba5ca891fa6a1f4f3a6f12789b87ccc1b484.zip |
pwait: verify pids exist at parse time
kill(pid, 0) will return ESRCH for nonexisting pids. (The other possible error, EPERM would indicate the pid exists.)
Diffstat (limited to 'pwait.c')
-rw-r--r-- | pwait.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/pwait.c b/pwait.c index e5f6fde..d32589d 100644 --- a/pwait.c +++ b/pwait.c @@ -184,6 +184,13 @@ usage: fprintf(stderr, "%s: invalid process id\n", argv[n]); continue; } + errno = 0; + kill(pid, 0); + if (errno == ESRCH) { + fprintf(stderr, "%s: no such process\n", argv[n]); + continue; + } + pids[m++] = pid; } |