syscall: disable cpu profiling around fork

Fixes #5517.
Fixes #5659.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12183044
This commit is contained in:
Dmitriy Vyukov 2013-08-13 13:01:30 +04:00
parent 9707f269c1
commit e33e476e07
4 changed files with 74 additions and 4 deletions

View file

@ -22,6 +22,10 @@ type SysProcAttr struct {
Pdeathsig Signal // Signal that the process will get when its parent dies (Linux only)
}
// Implemented in runtime package.
func runtime_BeforeFork()
func runtime_AfterFork()
// Fork, dup fd onto 0..len(fd), and exec(argv0, argvv, envv) in child.
// If a dup or exec fails, write the errno error to pipe.
// (Pipe is close-on-exec so if exec succeeds, it will be closed.)
@ -56,13 +60,16 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
// About to call fork.
// No more allocation or calls of non-assembly functions.
runtime_BeforeFork()
r1, _, err1 = RawSyscall(SYS_FORK, 0, 0, 0)
if err1 != 0 {
runtime_AfterFork()
return 0, err1
}
if r1 != 0 {
// parent; return PID
runtime_AfterFork()
return int(r1), 0
}