From df2d153e3991b7191aa54e90eb99e19eb6958e6b Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 13 Jan 2013 15:58:40 +0100 Subject: [PATCH] pty: reset signal-handlers for childs If signal-handlers are set to SIG_IGN, then this behavior is preserved across an execve(). We don't want that so reset the handlers for all childs before executing them. kmscon may be executed with pre-set signal handlers for good reasons. So reset the handlers in setup_child() so we have a clean environment. This fixes a bug where child-programs assume SIGPIPE is not ignored but do not explicitly set it to SIG_DFL. Reported-by: Swift Geek [github issue #62] Signed-off-by: David Herrmann --- src/pty.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pty.c b/src/pty.c index 46045d5..de2e512 100644 --- a/src/pty.c +++ b/src/pty.c @@ -269,7 +269,7 @@ static void setup_child(int master, struct winsize *ws) sigset_t sigset; pid_t pid; char slave_name[128]; - int slave = -1; + int slave = -1, i; struct termios attr; /* The child should not inherit our signal mask. */ @@ -278,6 +278,9 @@ static void setup_child(int master, struct winsize *ws) if (ret) log_warn("cannot reset blocked signals: %m"); + for (i = 1; i < SIGUNUSED; ++i) + signal(i, SIG_DFL); + ret = grantpt(master); if (ret < 0) { log_err("grantpt failed: %m");