summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>2017-10-03 12:05:24 +0100
committerSven Eden <yamakuzure@gmx.net>2017-10-03 12:05:24 +0100
commit7d729de3a70bc7a7fef69f5cea03fcbf835e118a (patch)
treef773ae98d3f151bc290269d21a9e25573f58e1b6 /src
parent50f665df3e070a0d3bdc7d9740986729f4bebc0b (diff)
Revert "tree-wide: use pid_is_valid() at more places"
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.
Diffstat (limited to 'src')
-rw-r--r--src/basic/process-util.c8
-rw-r--r--src/login/logind-dbus.c4
2 files changed, 6 insertions, 6 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c
index 22d6f5059..62c7acfa2 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -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())
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 63cd1a4d4..4d75e3e15 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -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) {