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.
This commit is contained in:
Daniel Eklöf 2021-12-05 15:25:26 +01:00
parent 197c1c5ced
commit e67639a682
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

7
main.c
View file

@ -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;
}