diff options
Diffstat (limited to 'src/firejail/join.c')
-rw-r--r-- | src/firejail/join.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/firejail/join.c b/src/firejail/join.c index 4259644f7..d05a4a465 100644 --- a/src/firejail/join.c +++ b/src/firejail/join.c | |||
@@ -41,7 +41,15 @@ static void signal_handler(int sig){ | |||
41 | exit(sig); | 41 | exit(sig); |
42 | } | 42 | } |
43 | 43 | ||
44 | 44 | static void install_handler(void) { | |
45 | struct sigaction sga; | ||
46 | |||
47 | // handle SIGTERM | ||
48 | sigemptyset(&sga.sa_mask); | ||
49 | sga.sa_handler = signal_handler; | ||
50 | sga.sa_flags = 0; | ||
51 | sigaction(SIGTERM, &sga, NULL); | ||
52 | } | ||
45 | 53 | ||
46 | static void extract_x11_display(pid_t pid) { | 54 | static void extract_x11_display(pid_t pid) { |
47 | char *fname; | 55 | char *fname; |
@@ -465,8 +473,19 @@ void join(pid_t pid, int argc, char **argv, int index) { | |||
465 | } | 473 | } |
466 | 474 | ||
467 | int status = 0; | 475 | int status = 0; |
476 | //***************************** | ||
477 | // following code is signal-safe | ||
478 | |||
479 | install_handler(); | ||
480 | |||
468 | // wait for the child to finish | 481 | // wait for the child to finish |
469 | waitpid(child, &status, 0); | 482 | waitpid(child, &status, 0); |
483 | |||
484 | // restore default signal action | ||
485 | signal(SIGTERM, SIG_DFL); | ||
486 | |||
487 | // end of signal-safe code | ||
488 | //***************************** | ||
470 | flush_stdin(); | 489 | flush_stdin(); |
471 | 490 | ||
472 | if (WIFEXITED(status)) { | 491 | if (WIFEXITED(status)) { |