aboutsummaryrefslogtreecommitdiff
path: root/src/rc.c
diff options
context:
space:
mode:
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);
}
}