diff options
author | Roy Marples <roy@marples.name> | 2008-05-06 21:53:21 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2008-05-06 21:53:21 +0000 |
commit | 619b0b4f37dbf05f8e30e15b839ed17ab1a21f5b (patch) | |
tree | 2b70fa77035eecab0573fa12a22c2356f68b2994 /src/rc/rc-plugin.c | |
parent | c8248d05a03209511f62c346d6c57ece38a87c6e (diff) |
Fix the EINTR check for waitpid, Gentoo #219929.
Diffstat (limited to 'src/rc/rc-plugin.c')
-rw-r--r-- | src/rc/rc-plugin.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/rc/rc-plugin.c b/src/rc/rc-plugin.c index 8599af6f..55112f4a 100644 --- a/src/rc/rc-plugin.c +++ b/src/rc/rc-plugin.c @@ -120,18 +120,25 @@ void rc_plugin_load(void) int rc_waitpid(pid_t pid) { - int status = 0; + int status; pid_t savedpid = pid; - 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; + +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; } void rc_plugin_run(RC_HOOK hook, const char *value) |