mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-13 04:27:47 -05:00
main: reset signal mask and signal handlers at startup
This ensures processes spawned by us (e.g. the shell, new terminal instances etc) don’t inherit a flawed signal mask, or having signals unknowingly ignored. Closes #854
This commit is contained in:
parent
63b12d4cdc
commit
8ca0eaa94c
2 changed files with 19 additions and 0 deletions
|
|
@ -82,6 +82,9 @@
|
|||
(https://codeberg.org/dnkl/foot/issues/379).
|
||||
* Line-based selections now include a trailing newline when copied
|
||||
(https://codeberg.org/dnkl/foot/issues/869).
|
||||
* Foot now clears the signal mask and resets all signal handlers to
|
||||
their default handlers at startup
|
||||
(https://codeberg.org/dnkl/foot/issues/854).
|
||||
|
||||
|
||||
### Deprecated
|
||||
|
|
|
|||
16
main.c
16
main.c
|
|
@ -152,6 +152,20 @@ print_pid(const char *pid_file, bool *unlink_at_exit)
|
|||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
sanitize_signals(void)
|
||||
{
|
||||
sigset_t mask;
|
||||
sigemptyset(&mask);
|
||||
sigprocmask(SIG_SETMASK, &mask, NULL);
|
||||
|
||||
struct sigaction dfl = {.sa_handler = SIG_DFL};
|
||||
sigemptyset(&dfl.sa_mask);
|
||||
|
||||
for (int i = 1; i < SIGRTMAX; i++)
|
||||
sigaction(i, &dfl, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *const *argv)
|
||||
{
|
||||
|
|
@ -160,6 +174,8 @@ main(int argc, char *const *argv)
|
|||
static const int foot_exit_failure = -26;
|
||||
int ret = foot_exit_failure;
|
||||
|
||||
sanitize_signals();
|
||||
|
||||
/* XDG startup notifications */
|
||||
const char *token = getenv("XDG_ACTIVATION_TOKEN");
|
||||
unsetenv("XDG_ACTIVATION_TOKEN");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue