aboutsummaryrefslogtreecommitdiff
path: root/src/rc.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-10-05 11:04:49 +0000
committerRoy Marples <roy@marples.name>2007-10-05 11:04:49 +0000
commit9ff89f8027fa904737f15d59e2c3b26950391933 (patch)
tree0f5edbb4e68125b994c2002a0311d9bad44725e5 /src/rc.c
parent3bfba57f5b2d89a5022fac932e46ca467a4b9f26 (diff)
Punt rc_waitpid
Diffstat (limited to 'src/rc.c')
-rw-r--r--src/rc.c21
1 files changed, 18 insertions, 3 deletions
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);
}
}