Skip to content
Snippets Groups Projects
Commit f0ee8be8 authored by Marius Vlad's avatar Marius Vlad
Browse files

terminal: Restore SIGPIPE signal handler to oldact (SIG_DFL)

Prior to executing a new command restore the parent process to the
default SIG_DLF handler as we normally use SIG_IGN it to avoid
crashing on pasted input.

As we seem to be hitting a Broken Pipe message when running
certain scripts, it seem we need to restore back the
default handler.

This is similar to what other folks have been doing in
https://github.com/labwc/labwc/issues/1209

.

Fixes: #994

Signed-off-by: default avatarMarius Vlad <marius.vlad@collabora.com>
parent 46f25304
No related branches found
No related tags found
1 merge request!1695terminal: Restore SIGPIPE to default
Pipeline #1387827 passed
...@@ -58,6 +58,7 @@ static char *option_term; ...@@ -58,6 +58,7 @@ static char *option_term;
static char *option_shell; static char *option_shell;
static struct wl_list terminal_list; static struct wl_list terminal_list;
struct sigaction oldact;
static struct terminal * static struct terminal *
terminal_create(struct display *display); terminal_create(struct display *display);
...@@ -3100,6 +3101,9 @@ terminal_run(struct terminal *terminal, const char *path) ...@@ -3100,6 +3101,9 @@ terminal_run(struct terminal *terminal, const char *path)
close(pipes[0]); close(pipes[0]);
setenv("TERM", option_term, 1); setenv("TERM", option_term, 1);
setenv("COLORTERM", option_term, 1); setenv("COLORTERM", option_term, 1);
sigaction(SIGPIPE, &oldact, NULL);
if (execl(path, path, NULL)) { if (execl(path, path, NULL)) {
printf("exec failed: %s\n", strerror(errno)); printf("exec failed: %s\n", strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -3177,8 +3181,10 @@ int main(int argc, char *argv[]) ...@@ -3177,8 +3181,10 @@ int main(int argc, char *argv[])
* socket whose reading end has been closed */ * socket whose reading end has been closed */
sigpipe.sa_handler = SIG_IGN; sigpipe.sa_handler = SIG_IGN;
sigemptyset(&sigpipe.sa_mask); sigemptyset(&sigpipe.sa_mask);
sigemptyset(&oldact.sa_mask);
sigpipe.sa_flags = 0; sigpipe.sa_flags = 0;
sigaction(SIGPIPE, &sigpipe, NULL); sigaction(SIGPIPE, &sigpipe, &oldact);
d = display_create(&argc, argv); d = display_create(&argc, argv);
if (d == NULL) { if (d == NULL) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment