Commit b92fba5c authored by Leah Neukirchen's avatar Leah Neukirchen

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.)
parent 86e7c446
## HEAD
* pwait: detect and warn for non-existing PID.
## 0.6 (2018-06-19)
* Add `-u` to print owner of process.
......
.Dd June 13, 2016
.Dd September 17, 2018
.Dt PWAIT 1
.Os
.Sh NAME
......@@ -22,6 +22,8 @@ Return 111 if any process exited non-successfully.
.El
.Sh EXIT STATUS
.Ex -std
.Pp
Invalid pids elicit a warning message but are otherwise ignored.
.Sh ERRORS
Check these prerequisites if you see this error:
.Bd -literal -offset Ds
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment