]> granicus.if.org Git - sysstat/commitdiff
mpstat/pidstat exit immediately when SIGINT caught during 1st interval
authorSebastien GODARD <sysstat@orange.fr.fake>
Fri, 20 Sep 2013 13:09:25 +0000 (15:09 +0200)
committerSebastien GODARD <sysstat@orange.fr.fake>
Fri, 20 Sep 2013 13:09:25 +0000 (15:09 +0200)
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.

mpstat.c
pidstat.c

index 1521755c0521cc9c9e4d97a72e58d01b9954ac74..e67838edaf5f4bca2c478e5b02dde12fd114d6a3 100644 (file)
--- a/mpstat.c
+++ b/mpstat.c
@@ -798,6 +798,10 @@ void rw_mpstat_loop(int dis_hdr, int rows)
        sigaction(SIGINT, &int_act, NULL);
 
        pause();
+       
+       if (sigint_caught)
+               /* SIGINT signal caught during first interval: Exit immediately */
+               return;
 
        do {
                /*
index be82a25080d8f57112cd77d4a98b073d88794388..192460f2a71dbc540a27352ed8022312e4bf7069 100644 (file)
--- a/pidstat.c
+++ b/pidstat.c
@@ -1948,6 +1948,10 @@ void rw_pidstat_loop(int dis_hdr, int rows)
        /* 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);