]> Cypherpunks repositories - gostls13.git/commit
runtime, syscall: reset signal handlers to default in child
authorIan Lance Taylor <iant@golang.org>
Tue, 13 Jun 2017 05:36:03 +0000 (22:36 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 14 Jun 2017 14:00:56 +0000 (14:00 +0000)
commitdf0892cbf854e76fae6e875043b05c194e37f52d
tree6d2ff62cf209f0f5bcaad476715d14a3caf8d667
parent17ba830f4663816c3270860fad96373a833a3b26
runtime, syscall: reset signal handlers to default in child

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: Austin Clements <austin@google.com>
src/runtime/crash_unix_test.go
src/runtime/os_nacl.go
src/runtime/os_plan9.go
src/runtime/os_windows.go
src/runtime/proc.go
src/runtime/signal_unix.go
src/runtime/testdata/testprognet/signalexec.go [new file with mode: 0644]
src/syscall/exec_bsd.go
src/syscall/exec_linux.go
src/syscall/exec_solaris.go