chiark / gitweb /
Revert "tree-wide: use pid_is_valid() at more places"
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Tue, 3 Oct 2017 11:05:24 +0000 (12:05 +0100)
committerSven Eden <yamakuzure@gmx.net>
Tue, 3 Oct 2017 11:05:24 +0000 (12:05 +0100)
This reverts commit ee043777be58251e7441b4f04594e9e3792d7fb2.

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.

src/basic/process-util.c
src/login/logind-dbus.c

index 22d6f5059b22bd5256065b8a33fa8e7ca6f9d107..62c7acfa2e738d4d637f5e0d6fddc49597247dd2 100644 (file)
@@ -478,7 +478,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");
@@ -793,7 +793,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 */
@@ -813,7 +813,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 */
@@ -833,7 +833,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())
index 63cd1a4d40921e1d369aa67d9441d83b6ed802cc..4d75e3e15e1ed8c13779abde9a8bb782098919e0 100644 (file)
@@ -348,7 +348,7 @@ static int method_get_session_by_pid(sd_bus_message *message, void *userdata, sd
         r = sd_bus_message_read(message, "u", &pid);
         if (r < 0)
                 return r;
-        if (!pid_is_valid((pid_t) pid))
+        if (pid < 0)
                 return -EINVAL;
 
         if (pid == 0) {
@@ -411,7 +411,7 @@ static int method_get_user_by_pid(sd_bus_message *message, void *userdata, sd_bu
         r = sd_bus_message_read(message, "u", &pid);
         if (r < 0)
                 return r;
-        if (!pid_is_valid((pid_t) pid))
+        if (pid < 0)
                 return -EINVAL;
 
         if (pid == 0) {