From: Davin McCall Date: Tue, 27 Jun 2017 08:54:31 +0000 (+0100) Subject: service: check error from kill when checking ability to track child. X-Git-Tag: v0.06~36 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0cf5edd103c7ad576f9c17e32cca59c75dbed3e0;p=oweals%2Fdinit.git service: check error from kill when checking ability to track child. We check whether the process exists using kill. We were treating any error return as meaning the process ID was invalid, but in fact we may simply not have permission to signal the process (if we are not being run as root and the service process is suid). --- diff --git a/src/service.cc b/src/service.cc index 892edcb..274e9f4 100644 --- a/src/service.cc +++ b/src/service.cc @@ -752,7 +752,7 @@ bgproc_service::read_pid_file(int *exit_status) noexcept pid_t wait_r = waitpid(pid, exit_status, WNOHANG); if (wait_r == -1 && errno == ECHILD) { // We can't track this child - check process exists: - if (kill(pid, 0) == 0) { + if (kill(pid, 0) == 0 || errno != ESRCH) { tracking_child = false; return pid_result_t::OK; }