aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-04-25 20:44:13 +0000
committerRoy Marples <roy@marples.name>2009-04-25 20:44:13 +0000
commit0feddbd815b16a23240f45dbdc38b36e3f1559e0 (patch)
treef5a4f46ed64d51b2f37468a2838da09968a5b9a6
parentbd6bb932dfbc6829f44dca3fc19366d8751ab06d (diff)
Use kill for the pid check as it's fast.
-rw-r--r--src/librc/librc-daemon.c11
1 files 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)))
{