On 06/04/2014 08:00 AM, Mohammad Merajul Islam Molla wrote:
Patch to fix the below two issues -

1. 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



--
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to