summaryrefslogtreecommitdiff
path: root/src/rc/rc-plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rc/rc-plugin.c')
-rw-r--r--src/rc/rc-plugin.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/rc/rc-plugin.c b/src/rc/rc-plugin.c
index 230a85a..8599af6 100644
--- a/src/rc/rc-plugin.c
+++ b/src/rc/rc-plugin.c
@@ -122,14 +122,15 @@ int rc_waitpid(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;
- }
-
+ int retval = EXIT_FAILURE;
+
+ do {
+ pid = waitpid(savedpid, &status, 0);
+ if (pid == -1 && errno != EINTR)
+ return EXIT_FAILURE;
+ } while (!WIFEXITED(status) && !WIFSIGNALED(status));
+ if (pid == savedpid)
+ retval = WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE;
return retval;
}