| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 54261f3 commit 7a80312
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -447,6 +447,17 @@ void ResetSignalHandlers() { | |||
| 447 | 447 | if (nr == SIGKILL || nr == SIGSTOP) | |
| 448 | 448 | continue; | |
| 449 | 449 | act.sa_handler = (nr == SIGPIPE || nr == SIGXFSZ) ? SIG_IGN : SIG_DFL; | |
| 450 | + if (act.sa_handler == SIG_DFL) { | ||
| 451 | + // The only bad handler value we can inhert from before exec is SIG_IGN | ||
| 452 | + // (any actual function pointer is reset to SIG_DFL during exec). | ||
| 453 | + // If that's the case, we want to reset it back to SIG_DFL. | ||
| 454 | + // However, it's also possible that an embeder (or an LD_PRELOAD-ed | ||
| 455 | + // library) has set up own signal handler for own purposes | ||
| 456 | + // (e.g. profiling). If that's the case, we want to keep it intact. | ||
| 457 | + struct sigaction old; | ||
| 458 | + CHECK_EQ(0, sigaction(nr, nullptr, &old)); | ||
| 459 | + if ((old.sa_flags & SA_SIGINFO) || old.sa_handler != SIG_IGN) continue; | ||
| 460 | + } | ||
| 450 | 461 | CHECK_EQ(0, sigaction(nr, &act, nullptr)); | |
| 451 | 462 | } | |
| 452 | 463 | #endif // __POSIX__ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments