aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-12-05 14:25:26 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-12-11 19:19:11 +0000
commite67639a6822c906b65b25850cd6c00738c2db648 (patch)
treef75c8b0f5d41616079531948de7a6fa1a249b99e
parentconfig: do key binding collision detection after loading the conf (diff)
main: ignore SIGPIPE
We want to handle SIGPIPEs without crashing... One way to trigger this was to use e.g. pipe-visible=[cat /foo/bar] Control+Shift+q That is, pipe output to something that did not consume it. This led to a SIGPIPE when we tried to write the terminal contents to the pipe, and crashed the whole foot instance.
-rw-r--r--main.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/main.c b/main.c
index 4f2dc7b6..b5a610e2 100644
--- a/main.c
+++ b/main.c
@@ -556,8 +556,11 @@ main(int argc, char *const *argv)
goto out;
}
- if (sigaction(SIGHUP, &(struct sigaction){.sa_handler = SIG_IGN}, NULL) < 0) {
- LOG_ERRNO("failed to ignore SIGHUP");
+ const struct sigaction sig_ign = {.sa_handler = SIG_IGN};
+ if (sigaction(SIGHUP, &sig_ign, NULL) < 0 ||
+ sigaction(SIGPIPE, &sig_ign, NULL) < 0)
+ {
+ LOG_ERRNO("failed to ignore SIGHUP+SIGPIPE");
goto out;
}