From 0feddbd815b16a23240f45dbdc38b36e3f1559e0 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Sat, 25 Apr 2009 20:44:13 +0000 Subject: Use kill for the pid check as it's fast. --- src/librc/librc-daemon.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c index 3c87faa2..34739c70 100644 --- a/src/librc/librc-daemon.c +++ b/src/librc/librc-daemon.c @@ -513,7 +513,8 @@ rc_service_daemons_crashed(const char *service) free(pidfile); pidfile = NULL; - /* We have the pid, so no need to match on exec or name */ + /* We have the pid, so no need to match + on exec or name */ free(exec); exec = NULL; free(name); @@ -530,7 +531,8 @@ rc_service_daemons_crashed(const char *service) } if (list) { - /* We need to flatten our linked list into an array */ + /* We need to flatten our linked list + into an array */ i = 0; TAILQ_FOREACH(s, list, entries) i++; @@ -543,7 +545,10 @@ rc_service_daemons_crashed(const char *service) } if (!retval) { - if ((pids = rc_find_pids(exec, + if (pid != 0) { + if (kill(pid, 0) == -1 && errno == ESRCH) + retval = true; + } else if ((pids = rc_find_pids(exec, (const char *const *)argv, 0, pid))) { -- cgit v1.2.3