Hello, I noticed some odd behaviors with idlestate.c/execute() function.
1. I wrote a sample program hello.c with infinite loop - int main() { while(1); } #sudo ../idlestat/idlestat -o /tmp/myoutput ../temp/hello idlestat never terminates, because there is no alarm set, hello program never terminates. 2. If I change and invoke idlestat with below command - #sudo ../idlestat/idlestat -o /tmp/myoutput -t 5 ../temp/hello idlestat outputs only below line and exits - Total trace buffer: 153896 kB What is happening is the below check fails - if (WIFSIGNALED(status) && WTERMSIG(status) == SIGTERM) { return 0; } here condition is always false. Because the status variable was fetched before killing the process. So status does not contain valid signal number. if (waitpid(pid, &status, 0) < 0) { if (errno != EINTR || !sigalrm) goto again; kill(pid, SIGTERM); } Possible Fix: call waitpid again after kill and fetch new status. 3. The below check makes idlestat dependent on the hello program run - if (WIFEXITED(status) && !WEXITSTATUS(status)) { } If my program is written to return a non-zero value, the second condition will be always false. So with the below program - int main() { return 1; } idlestat outputs only since WEXITSTATUS(status) returns nonzero value - Total trace buffer: 153896 kB Possible Fix: Just check WIFEXITED(status) and ommit the fetching of exit status. In any case, it should not be allowed to run idlestat with "-t 0", since that will results in problem 1 again. -- Thanks, - Meraj
_______________________________________________ linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev