diff options
author | Roy Marples <roy@marples.name> | 2008-05-07 09:47:07 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2008-05-07 09:47:07 +0000 |
commit | a854fe6d61257ff3dc6f4d2bc24baa42d80a9067 (patch) | |
tree | 1e22c89248dafd93612d5a4ddc959bb9a39e84c8 | |
parent | 619b0b4f37dbf05f8e30e15b839ed17ab1a21f5b (diff) |
Simplify the wait code.
-rw-r--r-- | src/rc/rc-plugin.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/rc/rc-plugin.c b/src/rc/rc-plugin.c index 55112f4a..92076730 100644 --- a/src/rc/rc-plugin.c +++ b/src/rc/rc-plugin.c @@ -121,24 +121,14 @@ void rc_plugin_load(void) int rc_waitpid(pid_t pid) { int status; - pid_t savedpid = pid; - -loop: - pid = waitpid(savedpid, &status, 0); - if (pid == -1) { - /* Our signal hander should take appropriate action. */ - if (errno == EINTR) - goto loop; - return EXIT_FAILURE; - } - - if (pid == savedpid) { - if (WIFEXITED(status)) - return WEXITSTATUS(status); - return EXIT_FAILURE; - } - return EXIT_SUCCESS; + while (waitpid(pid, &status, 0) == -1) { + if (errno != EINTR) { + status = -1; + break; + } + } + return status; } void rc_plugin_run(RC_HOOK hook, const char *value) |