Simplify the wait code.
This commit is contained in:
parent
619b0b4f37
commit
a854fe6d61
@ -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;
|
||||
while (waitpid(pid, &status, 0) == -1) {
|
||||
if (errno != EINTR) {
|
||||
status = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pid == savedpid) {
|
||||
if (WIFEXITED(status))
|
||||
return WEXITSTATUS(status);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
|
||||
void rc_plugin_run(RC_HOOK hook, const char *value)
|
||||
|
Loading…
Reference in New Issue
Block a user