diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2013-08-13 13:01:30 +0400 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2013-08-13 13:01:30 +0400 |
| commit | e33e476e074c3f424ca5b9d14cf67acacd5250aa (patch) | |
| tree | 17dc781f20f0f494e3429b5790a2077abbc36e1a /src/pkg/syscall | |
| parent | 9707f269c1eb7ee68a2be93e87eb49d481fb1a84 (diff) | |
| download | go-e33e476e074c3f424ca5b9d14cf67acacd5250aa.tar.xz | |
syscall: disable cpu profiling around fork
Fixes #5517.
Fixes #5659.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12183044
Diffstat (limited to 'src/pkg/syscall')
| -rw-r--r-- | src/pkg/syscall/exec_bsd.go | 7 | ||||
| -rw-r--r-- | src/pkg/syscall/exec_linux.go | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/pkg/syscall/exec_bsd.go b/src/pkg/syscall/exec_bsd.go index 249fa638dd..49f792cf00 100644 --- a/src/pkg/syscall/exec_bsd.go +++ b/src/pkg/syscall/exec_bsd.go @@ -21,6 +21,10 @@ type SysProcAttr struct { Noctty bool // Detach fd 0 from controlling terminal } +// 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.) @@ -57,8 +61,10 @@ 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, r2, err1 = RawSyscall(SYS_FORK, 0, 0, 0) if err1 != 0 { + runtime_AfterFork() return 0, err1 } @@ -72,6 +78,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr if r1 != 0 { // parent; return PID + runtime_AfterFork() return int(r1), 0 } diff --git a/src/pkg/syscall/exec_linux.go b/src/pkg/syscall/exec_linux.go index 934c657712..f332b7069c 100644 --- a/src/pkg/syscall/exec_linux.go +++ b/src/pkg/syscall/exec_linux.go @@ -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 } |
