[Bug 1692] sshd sometimes dies when sent multiple SIGHUPs in quick succession

bugzilla-daemon at bugzilla.mindrot.org bugzilla-daemon at bugzilla.mindrot.org
Wed Jan 6 12:18:03 EST 2010


https://bugzilla.mindrot.org/show_bug.cgi?id=1692

--- Comment #2 from Colin Watson <cjwatson at debian.org> 2010-01-06 12:18:01 EST ---
That isn't how execve() works, though. Signal dispositions are
inherited, not reset by the action of loading the new process image.
Lots of things wouldn't work if things were the way you posit - for
example, nohup(1) would be entirely non-functional.

Here's a transcript of a test demonstrating that ignoring SIGHUP before
execve() is effective. Does this convince you?

$ cat t.c
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
typedef void (*sighandler_t)(int);
extern char **environ;
int main(int argc, char **argv) {
    if (getenv("SECOND_TIME")) {
        sighandler_t prev = signal(SIGHUP, SIG_DFL);
        if (prev == SIG_IGN) {
            printf("SIGHUP was SIG_IGN\n");
        } else {
            printf("SIGHUP was not SIG_IGN\n");
        }
        exit(0);
    } else {
        setenv("SECOND_TIME", "1", 1);
        if (getenv("IGNORE_SIGHUP"))
            signal(SIGHUP, SIG_IGN);
        execve(argv[0], argv, environ);
    }
}
$ make t
cc     t.c   -o t
$ ./t
SIGHUP was not SIG_IGN
$ IGNORE_SIGHUP=1 ./t
SIGHUP was SIG_IGN

-- 
Configure bugmail: https://bugzilla.mindrot.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching the assignee of the bug.
You are watching someone on the CC list of the bug.


More information about the openssh-bugs mailing list