]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
process-util: check for correct kill return value (#10841)
authorDavid Leeds <david.leeds@chargepoint.com>
Tue, 20 Nov 2018 03:35:36 +0000 (19:35 -0800)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 20 Nov 2018 03:35:36 +0000 (12:35 +0900)
Code was not doing a wait() after kill() due to checking for a return value > 0, and was leaving zombie processes. This affected things like  sd-bus unixexec connections.

src/basic/process-util.c

index b3f69b2542b5af3b55d406ebf3ee97244adc99ab..8f7f4b5e25eb529a348567bb52ba8458144d62ef 100644 (file)
@@ -831,7 +831,7 @@ int wait_for_terminate_with_timeout(pid_t pid, usec_t timeout) {
 void sigkill_wait(pid_t pid) {
         assert(pid > 1);
 
-        if (kill(pid, SIGKILL) > 0)
+        if (kill(pid, SIGKILL) >= 0)
                 (void) wait_for_terminate(pid, NULL);
 }
 
@@ -849,7 +849,7 @@ void sigkill_waitp(pid_t *pid) {
 void sigterm_wait(pid_t pid) {
         assert(pid > 1);
 
-        if (kill_and_sigcont(pid, SIGTERM) > 0)
+        if (kill_and_sigcont(pid, SIGTERM) >= 0)
                 (void) wait_for_terminate(pid, NULL);
 }