• Ian Lance Taylor's avatar
    runtime, syscall: reset signal handlers to default in child · df0892cb
    Ian Lance Taylor authored
    Block all signals during a fork. In the parent process, after the
    fork, restore the signal mask. In the child process, reset all
    currently handled signals to the default handler, and then restore the
    signal mask.
    
    The effect of this is that the child will be operating using the same
    signal regime as the program it is about to exec, as exec resets all
    non-ignored signals to the default, and preserves the signal mask.
    
    We do this so that in the case of a signal sent to the process group,
    the child process will not try to run a signal handler while in the
    precarious state after a fork.
    
    Fixes #18600.
    
    Change-Id: I9f39aaa3884035908d687ee323c975f349d5faaa
    Reviewed-on: https://go-review.googlesource.com/45471
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarAustin Clements <austin@google.com>
    df0892cb
signalexec.go 1.26 KB