summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-05-07 09:47:07 +0000
committerRoy Marples <roy@marples.name>2008-05-07 09:47:07 +0000
commita854fe6d61257ff3dc6f4d2bc24baa42d80a9067 (patch)
tree1e22c89248dafd93612d5a4ddc959bb9a39e84c8
parent619b0b4f37dbf05f8e30e15b839ed17ab1a21f5b (diff)
downloadopenrc-a854fe6d61257ff3dc6f4d2bc24baa42d80a9067.tar.gz
openrc-a854fe6d61257ff3dc6f4d2bc24baa42d80a9067.tar.bz2
openrc-a854fe6d61257ff3dc6f4d2bc24baa42d80a9067.tar.xz
Simplify the wait code.
-rw-r--r--src/rc/rc-plugin.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/rc/rc-plugin.c b/src/rc/rc-plugin.c
index 55112f4..9207673 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)