diff options
author | Manuel Stoeckl <code@mstoeckl.com> | 2019-08-19 11:53:35 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-08-23 11:53:13 +0000 |
commit | 5f592c7855c4a1221facb282adb73156e949ecc0 (patch) | |
tree | 1577346bfc049ddd7acbded538fa11c897860c08 | |
parent | ec8c876e824d59239aca2b74e40be66142efac7c (diff) | |
download | weston-5f592c7855c4a1221facb282adb73156e949ecc0.tar.gz |
weston-terminal: Ignore SIGPIPE
This ensures that the default signal action doesn't kill weston-terminal
when the terminal tries to paste into a pipe whose read end has already
been shut down. (For example, a pipe from a misconfigured program or from
one which crashes/exits before the terminal calls write().)
Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
-rw-r--r-- | clients/terminal.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clients/terminal.c b/clients/terminal.c index 38e40207..ec767641 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -23,6 +23,7 @@ #include "config.h" +#include <signal.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> @@ -3127,6 +3128,7 @@ int main(int argc, char *argv[]) struct display *d; struct terminal *terminal; const char *config_file; + struct sigaction sigpipe; struct weston_config *config; struct weston_config_section *s; @@ -3157,6 +3159,14 @@ int main(int argc, char *argv[]) return 1; } + /* Disable SIGPIPE so that paste operations do not crash the program + * when the file descriptor provided to receive data is a pipe or + * socket whose reading end has been closed */ + sigpipe.sa_handler = SIG_IGN; + sigemptyset(&sigpipe.sa_mask); + sigpipe.sa_flags = 0; + sigaction(SIGPIPE, &sigpipe, NULL); + d = display_create(&argc, argv); if (d == NULL) { fprintf(stderr, "failed to create display: %s\n", |