pty: reset signal-handlers for childs
authorDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 13 Jan 2013 14:58:40 +0000 (15:58 +0100)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 13 Jan 2013 14:58:40 +0000 (15:58 +0100)
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 <dh.herrmann@googlemail.com>
src/pty.c

index 46045d5..de2e512 100644 (file)
--- 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");