mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
17ba830f46
commit
df0892cbf8
10 changed files with 158 additions and 10 deletions
|
|
@ -23,6 +23,7 @@ type SysProcAttr struct {
|
|||
// Implemented in runtime package.
|
||||
func runtime_BeforeFork()
|
||||
func runtime_AfterFork()
|
||||
func runtime_AfterForkInChild()
|
||||
|
||||
func chdir(path uintptr) (err Errno)
|
||||
func chroot1(path uintptr) (err Errno)
|
||||
|
|
@ -93,6 +94,8 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
|
|||
|
||||
// Fork succeeded, now in child.
|
||||
|
||||
runtime_AfterForkInChild()
|
||||
|
||||
// Session ID
|
||||
if sys.Setsid {
|
||||
_, err1 = setsid()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue