From 0cf5edd103c7ad576f9c17e32cca59c75dbed3e0 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Tue, 27 Jun 2017 09:54:31 +0100 Subject: [PATCH] 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). --- src/service.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } -- 2.25.1