From: Pavel Charvat Date: Fri, 10 Oct 2014 12:56:58 +0000 (+0000) Subject: Daemon: Fixed more race conditions. X-Git-Tag: v6.1.1^0 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=276364d29ca149e30344e3eab91cb93dd6beecd6;p=libucw.git Daemon: Fixed more race conditions. --- diff --git a/ucw/daemon-ctrl.c b/ucw/daemon-ctrl.c index 029a39d9..6834b0c8 100644 --- a/ucw/daemon-ctrl.c +++ b/ucw/daemon-ctrl.c @@ -187,7 +187,7 @@ daemon_control(struct daemon_control_params *dc) if (pid) { sig = dc->signal ? : SIGTERM; - if (kill(pid, sig) < 0) + if (kill(pid, sig) < 0 && errno != ESRCH) { st = daemon_control_err(dc, "Cannot send signal %d: %m", sig); goto done; @@ -205,10 +205,12 @@ daemon_control(struct daemon_control_params *dc) if (!pid) return DAEMON_STATUS_NOT_RUNNING; sig = dc->signal ? : SIGHUP; - if (kill(pid, sig) < 0) - st = daemon_control_err(dc, "Cannot send signal %d: %m", sig); - else + if (kill(pid, sig) >= 0) st = DAEMON_STATUS_OK; + else if (errno == ESRCH) + st = DAEMON_STATUS_NOT_RUNNING; + else + st = daemon_control_err(dc, "Cannot send signal %d: %m", sig); break; default: ASSERT(0);