The mpstat and pidstat commands display their average statistics when
they are interrupted by the user with control-C (SIGINT signal).
But when the signal was caught during the first interval of time (ie.
before any statistics had been displayed), trying to display some
average values is irrelevant. So make them exit immediately in this
case.
sigaction(SIGINT, &int_act, NULL);
pause();
+
+ if (sigint_caught)
+ /* SIGINT signal caught during first interval: Exit immediately */
+ return;
do {
/*
/* Wait for SIGALRM (or possibly SIGINT) signal */
pause();
+ if (sigint_caught)
+ /* SIGINT signal caught during first interval: Exit immediately */
+ return;
+
do {
/* Get time */
get_localtime(&ps_tstamp[curr], 0);