Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SEGFAULT at terminal resize #222

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions app/pktgen-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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();
Expand Down
Loading