On 06/04/2014 08:00 AM, Mohammad Merajul Islam Molla wrote:
Patch to fix the below two issues -
- Fix the part where parent waits to fetch child status. In case
SIGALRM is received, fetch new status after killing child so that subsequent check for termination status passes. 2. In case of normal termination, just check if program exited normally (checking exit status is not necessary)
Sounds good.
Thanks for the patch.
-- Daniel
diff --git a/idlestat.c b/idlestat.c index 787d7b0..179e7a7 100644 --- a/idlestat.c +++ b/idlestat.c @@ -1196,12 +1196,12 @@ static int execute(int argc, char *argv[], char *const envp[], alarm(options->duration); again: if (waitpid(pid, &status, 0) < 0) {
if (errno != EINTR || !sigalrm)
goto again;
kill(pid, SIGTERM);
if (errno == EINTR && sigalrm)
kill(pid, SIGTERM);
goto again; }
if (WIFEXITED(status) && !WEXITSTATUS(status)) {
if (WIFEXITED(status)) { /* * Cancel the timer in case the program * finished before the timeout
-- Thanks, -Meraj