From: Huang Ying Date: Sun, 3 Mar 2019 06:11:29 +0000 (+0800) Subject: Fix missing "}" and "]" in JSON output when stopped by SIGINT X-Git-Tag: v12.1.4~58^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=021dd04dedf30d94d155bcc7c8926d1a93e30c5b;p=sysstat Fix missing "}" and "]" in JSON output when stopped by SIGINT 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. --- diff --git a/mpstat.c b/mpstat.c index 47ea209..0a10790 100644 --- 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();