From 9ff89f8027fa904737f15d59e2c3b26950391933 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 5 Oct 2007 11:04:49 +0000 Subject: Punt rc_waitpid --- src/rc.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/rc.c') diff --git a/src/rc.c b/src/rc.c index ffcfffe5..9472edb5 100644 --- a/src/rc.c +++ b/src/rc.c @@ -623,6 +623,21 @@ static void remove_pid (pid_t pid) } } +static int wait_pid (pid_t pid) +{ + int status = 0; + pid_t savedpid = pid; + int retval = -1; + + errno = 0; + while ((pid = waitpid (savedpid, &status, 0)) > 0) { + if (pid == savedpid) + retval = WIFEXITED (status) ? WEXITSTATUS (status) : EXIT_FAILURE; + } + + return (retval); +} + static void handle_signal (int sig) { int serrno = errno; @@ -1212,7 +1227,7 @@ int main (int argc, char **argv) if (going_down) { pid_t pid = rc_service_stop (service); if (pid > 0 && ! rc_env_bool ("RC_PARALLEL")) - rc_waitpid (pid); + wait_pid (pid); continue; } @@ -1277,7 +1292,7 @@ int main (int argc, char **argv) if (! found) { pid_t pid = rc_service_stop (service); if (pid > 0 && ! rc_env_bool ("RC_PARALLEL")) - rc_waitpid (pid); + wait_pid (pid); } } rc_strlist_free (types); @@ -1379,7 +1394,7 @@ interactive_option: add_pid (pid); if (! rc_env_bool ("RC_PARALLEL")) { - rc_waitpid (pid); + wait_pid (pid); remove_pid (pid); } } -- cgit v1.2.3