-
Notifications
You must be signed in to change notification settings - Fork 119
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
app/pktgen-main.c
Outdated
* can handle screen resizes */ | ||
sigemptyset(&set); | ||
sigaddset(&set, SIGWINCH); | ||
pthread_sigmask(SIG_BLOCK, &set, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed this code looks exactly like the code at line 440, but this one states unblock and the other states block. Should line 582 use SIG_UNBLOCK instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, thank you.
this_cli is a thread-local variable used by functions within SIGWINCH signal handler. This means that it can only be accessed by the main thread (that created it). Previosly however this signal could be handled by any thread of the process, thus occasionally causing SEGFAULTs. In a multithreaded process if a signal is blocked by all threads but one, then the signal will be delivered to the thread expecting it. Using the fact that signal masks are inherited by pthreads this commit blocks SIGWINCH in the beginning of main(before the workers and the screen timer are spawned) and unblocks it just before cli_start(). The unblocking could be moved to scrn_start() function. An alternative to this could be adding a 'handle_winch' atomic to struct cli_scrn. Signed-off-by: Philipp <phila775@gmail.com>
2853779
to
283d2e6
Compare
Corrected the typo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
this_cli is a thread-local variable used by functions within SIGWINCH signal handler. This means that it can only be accessed by the main thread (that created it). Previosly however this signal could be handled by any thread of the process, thus occasionally causing SEGFAULTs.
In a multithreaded process if a signal is blocked by all threads but one, then the signal will be delivered to the thread expecting it. Using the fact that signal masks are inherited by pthreads this commit blocks SIGWINCH in the beginning of main(before the workers and the screen timer are spawned) and unblocks it just before cli_start().
The unblocking could be moved to scrn_start() function.
An alternative to this could be adding a 'handle_winch' atomic to struct cli_scrn.
Fixes #220