aboutsummaryrefslogtreecommitdiff
path: root/src/librc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/librc.c')
-rw-r--r--src/librc.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/librc.c b/src/librc.c
index 728f1c45..f501719e 100644
--- a/src/librc.c
+++ b/src/librc.c
@@ -558,18 +558,15 @@ static pid_t _exec_service (const char *service, const char *arg)
int rc_waitpid (pid_t pid) {
int status = 0;
pid_t savedpid = pid;
+ int retval = -1;
errno = 0;
- do {
- pid = waitpid (savedpid, &status, 0);
- if (pid < 0) {
- if (errno != ECHILD)
- eerror ("waitpid %d: %s", savedpid, strerror (errno));
- return (-1);
- }
- } while (! WIFEXITED (status) && ! WIFSIGNALED (status));
-
- return (WIFEXITED (status) ? WEXITSTATUS (status) : EXIT_FAILURE);
+ while ((pid = waitpid (savedpid, &status, 0)) > 0) {
+ if (pid == savedpid)
+ retval = WIFEXITED (status) ? WEXITSTATUS (status) : EXIT_FAILURE;
+ }
+
+ return (retval);
}
pid_t rc_stop_service (const char *service)