diff --git a/app/cli-functions.c b/app/cli-functions.c index fe96b2fb..32eac42c 100644 --- a/app/cli-functions.c +++ b/app/cli-functions.c @@ -836,11 +836,11 @@ pcap_cmd(int argc, char **argv) switch (m->index) { case 10: - pcap = pktgen.info[pktgen.portNum].pcap; - max_cnt = pcap->pkt_count; - value = strtoul(argv[1], NULL, 10); + pcap = pktgen.info[pktgen.portNum].pcap; + value = strtoul(argv[1], NULL, 10); if (pcap) { + max_cnt = pcap->pkt_count; if (value >= max_cnt) pcap->pkt_idx = max_cnt - RTE_MIN(PCAP_PAGE_SIZE, (int)max_cnt); else diff --git a/app/pktgen-main.c b/app/pktgen-main.c index 83d931cf..fa3a2108 100644 --- a/app/pktgen-main.c +++ b/app/pktgen-main.c @@ -420,13 +420,26 @@ main(int argc, char **argv) { uint32_t i; int32_t ret; + struct sigaction sa; + sigset_t set; setlocale(LC_ALL, ""); - signal(SIGSEGV, sig_handler); - signal(SIGHUP, sig_handler); - signal(SIGINT, sig_handler); - signal(SIGPIPE, sig_handler); + sa.sa_handler = sig_handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + + sigaction(SIGSEGV, &sa, NULL); + sigaction(SIGHUP, &sa, NULL); + sigaction(SIGINT, &sa, NULL); + sigaction(SIGPIPE, &sa, NULL); + + /* Block SIGWINCH for all threads, + * because we only want it to be + * handled by the main thread */ + sigemptyset(&set); + sigaddset(&set, SIGWINCH); + pthread_sigmask(SIG_BLOCK, &set, NULL); scrn_setw(1); /* Reset the window size, from possible crash run. */ scrn_pos(100, 1); /* Move the cursor to the bottom of the screen again */ @@ -561,6 +574,13 @@ main(int argc, char **argv) } pktgen_log_info("=== Run CLI\n"); + + /* Unblock SIGWINCH so main thread + * can handle screen resizes */ + sigemptyset(&set); + sigaddset(&set, SIGWINCH); + pthread_sigmask(SIG_UNBLOCK, &set, NULL); + cli_start(NULL); scrn_pause();