diff options
Diffstat (limited to 'src/pkg/syscall/exec_bsd.go')
| -rw-r--r-- | src/pkg/syscall/exec_bsd.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/pkg/syscall/exec_bsd.go b/src/pkg/syscall/exec_bsd.go index 5d3d57813..ff78f197f 100644 --- a/src/pkg/syscall/exec_bsd.go +++ b/src/pkg/syscall/exec_bsd.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin freebsd netbsd openbsd +// +build darwin dragonfly freebsd netbsd openbsd package syscall @@ -21,12 +21,17 @@ 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.) // In the child, this function must not acquire any locks, because // they might have been locked at the time of the fork. This means // no rescheduling, no malloc calls, and no new stack segments. +// For the same reason compiler does not race instrument it. // The calls to RawSyscall are okay because they are assembly // functions that do not grow the stack. func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr *ProcAttr, sys *SysProcAttr, pipe int) (pid int, err Errno) { @@ -56,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 } @@ -71,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 } |
