]> granicus.if.org Git - sysstat/commitdiff
Fix missing "}" and "]" in JSON output when stopped by SIGINT
authorHuang Ying <ying.huang@intel.com>
Sun, 3 Mar 2019 06:11:29 +0000 (14:11 +0800)
committerHuang Ying <ying.huang@intel.com>
Sun, 3 Mar 2019 06:11:29 +0000 (14:11 +0800)
When mpstat is stopped by SIGINT, the JSON output will miss the
trailing "}" and "]" because SIGINT handler isn't called.  Fixed this
via setup SIGINT handler for JSON output too.

mpstat.c

index 47ea209caf25eb7fc37c71d3a238f1ea3822a971..0a10790c83c6754ba3bddd0f54a52b5b552f8d99 100644 (file)
--- a/mpstat.c
+++ b/mpstat.c
@@ -1871,12 +1871,10 @@ void rw_mpstat_loop(int dis_hdr, int rows)
                       STATS_IRQCPU_SIZE * (cpu_nr + 1) * softirqcpu_nr);
        }
 
-       if (!DISPLAY_JSON_OUTPUT(flags)) {
-               /* Set a handler for SIGINT */
-               memset(&int_act, 0, sizeof(int_act));
-               int_act.sa_handler = int_handler;
-               sigaction(SIGINT, &int_act, NULL);
-       }
+       /* Set a handler for SIGINT */
+       memset(&int_act, 0, sizeof(int_act));
+       int_act.sa_handler = int_handler;
+       sigaction(SIGINT, &int_act, NULL);
 
        pause();