Commit 5f592c78 authored by Manuel Stoeckl's avatar Manuel Stoeckl Committed by Simon Ser

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: default avatarManuel Stoeckl <code@mstoeckl.com>
parent ec8c876e
Pipeline #58296 passed with stages
in 1 minute and 22 seconds
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "config.h" #include "config.h"
#include <signal.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
...@@ -3127,6 +3128,7 @@ int main(int argc, char *argv[]) ...@@ -3127,6 +3128,7 @@ int main(int argc, char *argv[])
struct display *d; struct display *d;
struct terminal *terminal; struct terminal *terminal;
const char *config_file; const char *config_file;
struct sigaction sigpipe;
struct weston_config *config; struct weston_config *config;
struct weston_config_section *s; struct weston_config_section *s;
...@@ -3157,6 +3159,14 @@ int main(int argc, char *argv[]) ...@@ -3157,6 +3159,14 @@ int main(int argc, char *argv[])
return 1; 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); d = display_create(&argc, argv);
if (d == NULL) { if (d == NULL) {
fprintf(stderr, "failed to create display: %s\n", fprintf(stderr, "failed to create display: %s\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment