chiark / gitweb /
tree-wide: use pid_is_valid() at more places
authorLennart Poettering <lennart@poettering.net>
Thu, 31 Aug 2017 08:25:06 +0000 (10:25 +0200)
committerSven Eden <yamakuzure@gmx.net>
Thu, 31 Aug 2017 08:25:06 +0000 (10:25 +0200)
src/basic/process-util.c
src/login/logind-dbus.c

index 4dcb93f2db875b81d231292e0d331fb5a36a8d0b..98f5a38ae5789d0b9bb99ceeabcc99537c503821 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 < 0)
+        if (!pid_is_valid(pid))
                 return -EINVAL;
 
         p = procfs_file_alloca(pid, "status");
@@ -794,7 +794,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 < 0)
+        if (!pid_is_valid(pid))
                 return false;
 
         if (pid <= 1) /* If we or PID 1 would be dead and have been waited for, this code would not be running */
@@ -814,7 +814,7 @@ bool pid_is_alive(pid_t pid) {
 
         /* Checks whether a PID is still valid and not a zombie */
 
-        if (pid < 0)
+        if (!pid_is_valid(pid))
                 return false;
 
         if (pid <= 1) /* If we or PID 1 would be a zombie, this code would not be running */
@@ -834,7 +834,7 @@ bool pid_is_alive(pid_t pid) {
 int pid_from_same_root_fs(pid_t pid) {
         const char *root;
 
-        if (pid < 0)
+        if (!pid_is_valid(pid))
                 return false;
 
         if (pid == 0 || pid == getpid_cached())
index 8da2eb63f08395a639499991ac387c740448610e..e80b778cf711a5a3fae1c29625c142502f4da3a1 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 < 0)
+        if (!pid_is_valid((pid_t) pid))
                 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 < 0)
+        if (!pid_is_valid((pid_t) pid))
                 return -EINVAL;
 
         if (pid == 0) {