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>
This commit is contained in:
committed by
Simon Ser
parent
ec8c876e82
commit
5f592c7855
@@ -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[])
|
|||||||
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[])
|
|||||||
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",
|
||||||
|
|||||||
Reference in New Issue
Block a user