chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
abc8019
)
process-util: make some minor corrections to PID live detection
author
Lennart Poettering
<lennart@poettering.net>
Tue, 27 Oct 2015 13:02:45 +0000
(14:02 +0100)
committer
Sven Eden
<yamakuzure@gmx.net>
Wed, 26 Apr 2017 10:58:55 +0000
(12:58 +0200)
src/basic/process-util.c
patch
|
blob
|
history
diff --git
a/src/basic/process-util.c
b/src/basic/process-util.c
index 8a1f54db81b61fd6949401cb81b389e4b9942b54..5825944c90414a954f14a3fb4c05de9ff60b55cc 100644
(file)
--- a/
src/basic/process-util.c
+++ b/
src/basic/process-util.c
@@
-556,9
+556,12
@@
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 */
bool pid_is_unwaited(pid_t pid) {
/* Checks whether a PID is still valid at all, including a zombie */
- if (pid <
=
0)
+ if (pid < 0)
return false;
return false;
+ if (pid <= 1) /* If we or PID 1 would be dead and have been waited for, this code would not be running */
+ return true;
+
if (kill(pid, 0) >= 0)
return true;
if (kill(pid, 0) >= 0)
return true;
@@
-570,9
+573,12
@@
bool pid_is_alive(pid_t pid) {
/* Checks whether a PID is still valid and not a zombie */
/* Checks whether a PID is still valid and not a zombie */
- if (pid <
=
0)
+ if (pid < 0)
return false;
return false;
+ if (pid <= 1) /* If we or PID 1 would be a zombie, this code would not be running */
+ return true;
+
r = get_process_state(pid);
if (r == -ESRCH || r == 'Z')
return false;
r = get_process_state(pid);
if (r == -ESRCH || r == 'Z')
return false;