Revert "tree-wide: use pid_is_valid() at more places"

This reverts commit ee043777be.

It broke almost everywhere it touched.  The places that
handn't been converted, were mostly followed by special
handling for the invalid PID `0`.  That explains why they
tested for `pid < 0` instead of `pid <= 0`.

I think that one was the first commit I reviewed, heh.
This commit is contained in:
Alan Jenkins
2017-10-03 12:43:24 +01:00
parent b139c95bc4
commit 07b38ba51e
5 changed files with 10 additions and 12 deletions
+4 -4
View File
@@ -475,7 +475,7 @@ static int get_process_id(pid_t pid, const char *field, uid_t *uid) {
assert(field);
assert(uid);
if (!pid_is_valid(pid))
if (pid < 0)
return -EINVAL;
p = procfs_file_alloca(pid, "status");
@@ -787,7 +787,7 @@ int getenv_for_pid(pid_t pid, const char *field, char **_value) {
bool pid_is_unwaited(pid_t pid) {
/* Checks whether a PID is still valid at all, including a zombie */
if (!pid_is_valid(pid))
if (pid < 0)
return false;
if (pid <= 1) /* If we or PID 1 would be dead and have been waited for, this code would not be running */
@@ -807,7 +807,7 @@ bool pid_is_alive(pid_t pid) {
/* Checks whether a PID is still valid and not a zombie */
if (!pid_is_valid(pid))
if (pid < 0)
return false;
if (pid <= 1) /* If we or PID 1 would be a zombie, this code would not be running */
@@ -826,7 +826,7 @@ bool pid_is_alive(pid_t pid) {
int pid_from_same_root_fs(pid_t pid) {
const char *root;
if (!pid_is_valid(pid))
if (pid < 0)
return false;
if (pid == 0 || pid == getpid_cached())