aboutsummaryrefslogtreecommitdiff
path: root/spawn.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-06-02 15:48:57 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-06-02 18:13:14 +0000
commita72b2688bda87a20d029e80eaf8d6686ca95003e (patch)
tree7cd36921a87903a498c4e2372bfa7c4cd92781c3 /spawn.c
parentMerge branch 'dont-split-multi-column-chars-when-resizing-alt-screen' (diff)
slave/spawn: restore SIGHUP handler after fork(), before exec()
Foot installs a SIG_IGN handler for SIGHUP. Ignored signals are inherited in sub-processes. Thus, we need to restore it to SIG_DFL before exec:ing.
Diffstat (limited to 'spawn.c')
-rw-r--r--spawn.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/spawn.c b/spawn.c
index 99f1dc7e..22f0d1ed 100644
--- a/spawn.c
+++ b/spawn.c
@@ -44,6 +44,10 @@ spawn(struct reaper *reaper, const char *cwd, char *const argv[],
if (sigprocmask(SIG_SETMASK, &mask, NULL) < 0)
goto child_err;
+ /* Restore ignored (SIG_IGN) signals */
+ if (sigaction(SIGHUP, &(struct sigaction){.sa_handler = SIG_DFL}, NULL) < 0)
+ goto child_err;
+
bool close_stderr = stderr_fd >= 0;
bool close_stdout = stdout_fd >= 0 && stdout_fd != stderr_fd;
bool close_stdin = stdin_fd >= 0 && stdin_fd != stdout_fd && stdin_fd != stderr_fd;