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 rc_waitpid(pid_t pid)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
pid_t savedpid = pid;
|
|
||||||
|
|
||||||
loop:
|
while (waitpid(pid, &status, 0) == -1) {
|
||||||
pid = waitpid(savedpid, &status, 0);
|
if (errno != EINTR) {
|
||||||
if (pid == -1) {
|
status = -1;
|
||||||
/* Our signal hander should take appropriate action. */
|
break;
|
||||||
if (errno == EINTR)
|
|
||||||
goto loop;
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pid == savedpid) {
|
|
||||||
if (WIFEXITED(status))
|
|
||||||
return WEXITSTATUS(status);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
return status;
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rc_plugin_run(RC_HOOK hook, const char *value)
|
void rc_plugin_run(RC_HOOK hook, const char *value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user