Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1261)

Delta Between Two Patch Sets: src/pkg/syscall/exec_unix.go

Issue 4253052: code review 4253052: os, syscall: add ProcAttributes type. Change StartProce... (Closed)
Left Patch Set: diff -r 611653f358d7 https://go.googlecode.com/hg/ Created 14 years ago
Right Patch Set: diff -r 6e3dda8b91b3 https://go.googlecode.com/hg/ Created 14 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/os/os_test.go ('k') | src/pkg/syscall/exec_windows.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Fork, exec, wait, etc. 5 // Fork, exec, wait, etc.
6 6
7 package syscall 7 package syscall
8 8
9 import ( 9 import (
10 "sync" 10 "sync"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // no rescheduling, no malloc calls, and no new stack segments. 96 // no rescheduling, no malloc calls, and no new stack segments.
97 // The calls to RawSyscall are okay because they are assembly 97 // The calls to RawSyscall are okay because they are assembly
98 // functions that do not grow the stack. 98 // functions that do not grow the stack.
99 func forkAndExecInChild(argv0 *byte, argv, envv []*byte, dir *byte, attr *ProcAt tr, pipe int) (pid int, err int) { 99 func forkAndExecInChild(argv0 *byte, argv, envv []*byte, dir *byte, attr *ProcAt tr, pipe int) (pid int, err int) {
100 // Declare all variables at top in case any 100 // Declare all variables at top in case any
101 // declarations require heap allocation (e.g., err1). 101 // declarations require heap allocation (e.g., err1).
102 var r1, r2, err1 uintptr 102 var r1, r2, err1 uintptr
103 var nextfd int 103 var nextfd int
104 var i int 104 var i int
105 105
106 » // we could copy this if we cared about the side effects, but this is sy scall. 106 » // guard against side effects of shuffling fds below.
107 » fd := attr.Files 107 » fd := append([]int(nil), attr.Files...)
108 108
109 darwin := OS == "darwin" 109 darwin := OS == "darwin"
110 110
111 // About to call fork. 111 // About to call fork.
112 // No more allocation or calls of non-assembly functions. 112 // No more allocation or calls of non-assembly functions.
113 r1, r2, err1 = RawSyscall(SYS_FORK, 0, 0, 0) 113 r1, r2, err1 = RawSyscall(SYS_FORK, 0, 0, 0)
114 if err1 != 0 { 114 if err1 != 0 {
115 return 0, int(err1) 115 return 0, int(err1)
116 } 116 }
117 117
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 335 }
336 336
337 // Ordinary exec. 337 // Ordinary exec.
338 func Exec(argv0 string, argv []string, envv []string) (err int) { 338 func Exec(argv0 string, argv []string, envv []string) (err int) {
339 _, _, err1 := RawSyscall(SYS_EXECVE, 339 _, _, err1 := RawSyscall(SYS_EXECVE,
340 uintptr(unsafe.Pointer(StringBytePtr(argv0))), 340 uintptr(unsafe.Pointer(StringBytePtr(argv0))),
341 uintptr(unsafe.Pointer(&StringArrayPtr(argv)[0])), 341 uintptr(unsafe.Pointer(&StringArrayPtr(argv)[0])),
342 uintptr(unsafe.Pointer(&StringArrayPtr(envv)[0]))) 342 uintptr(unsafe.Pointer(&StringArrayPtr(envv)[0])))
343 return int(err1) 343 return int(err1)
344 } 344 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b