Use kill for the pid check as it's fast.

This commit is contained in:
Roy Marples 2009-04-25 20:44:13 +00:00
parent bd6bb932df
commit 0feddbd815

View File

@ -513,7 +513,8 @@ rc_service_daemons_crashed(const char *service)
free(pidfile); free(pidfile);
pidfile = NULL; 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); free(exec);
exec = NULL; exec = NULL;
free(name); free(name);
@ -530,7 +531,8 @@ rc_service_daemons_crashed(const char *service)
} }
if (list) { if (list) {
/* We need to flatten our linked list into an array */ /* We need to flatten our linked list
into an array */
i = 0; i = 0;
TAILQ_FOREACH(s, list, entries) TAILQ_FOREACH(s, list, entries)
i++; i++;
@ -543,7 +545,10 @@ rc_service_daemons_crashed(const char *service)
} }
if (!retval) { 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, (const char *const *)argv,
0, pid))) 0, pid)))
{ {