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

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

Issue 4029053: code review 4029053: os: implement new Process api (Closed)
Left Patch Set: code review 4029053: os: implement new Process api Created 13 years, 1 month ago
Right Patch Set: diff -r 75ebb1ad8e98 https://go.googlecode.com/hg/ Created 13 years, 1 month 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/syscall/exec_unix.go ('k') | src/pkg/syscall/syscall_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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 j++ 100 j++
101 qs[i+j] = rune 101 qs[i+j] = rune
102 } 102 }
103 } 103 }
104 qs[len(qs)-1] = rune 104 qs[len(qs)-1] = rune
105 return string(qs) 105 return string(qs)
106 } 106 }
107 107
108 108
109 func CloseOnExec(fd int) { 109 func CloseOnExec(fd int) {
110 » return 110 » SetHandleInformation(int32(fd), HANDLE_FLAG_INHERIT, 0)
111 } 111 }
112 112
113 func SetNonblock(fd int, nonblocking bool) (errno int) { 113 func SetNonblock(fd int, nonblocking bool) (errno int) {
114 return 0 114 return 0
115 } 115 }
116 116
117 117
118 // TODO(kardia): Add trace 118 // TODO(kardia): Add trace
119 //The command and arguments are passed via the Command line parameter. 119 //The command and arguments are passed via the Command line parameter.
120 func StartProcess(argv0 string, argv []string, envv []string, dir string, fd []i nt) (pid, handle int, err int) { 120 func StartProcess(argv0 string, argv []string, envv []string, dir string, fd []i nt) (pid, handle int, err int) {
(...skipping 11 matching lines...) Expand all
132 132
133 startupInfo := new(StartupInfo) 133 startupInfo := new(StartupInfo)
134 processInfo := new(ProcessInformation) 134 processInfo := new(ProcessInformation)
135 135
136 GetStartupInfo(startupInfo) 136 GetStartupInfo(startupInfo)
137 137
138 startupInfo.Flags = STARTF_USESTDHANDLES 138 startupInfo.Flags = STARTF_USESTDHANDLES
139 startupInfo.StdInput = 0 139 startupInfo.StdInput = 0
140 startupInfo.StdOutput = 0 140 startupInfo.StdOutput = 0
141 startupInfo.StdErr = 0 141 startupInfo.StdErr = 0
142
143 // Acquire the fork lock so that no other threads
144 // create new fds that are not yet close-on-exec
145 // before we fork.
146 ForkLock.Lock()
147 defer ForkLock.Unlock()
142 148
143 var currentProc, _ = GetCurrentProcess() 149 var currentProc, _ = GetCurrentProcess()
144 if len(fd) > 0 && fd[0] > 0 { 150 if len(fd) > 0 && fd[0] > 0 {
145 if ok, err := DuplicateHandle(currentProc, int32(fd[0]), current Proc, &startupInfo.StdInput, 0, true, DUPLICATE_SAME_ACCESS); !ok { 151 if ok, err := DuplicateHandle(currentProc, int32(fd[0]), current Proc, &startupInfo.StdInput, 0, true, DUPLICATE_SAME_ACCESS); !ok {
146 return 0, 0, err 152 return 0, 0, err
147 } 153 }
148 defer CloseHandle(int32(startupInfo.StdInput)) 154 defer CloseHandle(int32(startupInfo.StdInput))
149 } 155 }
150 if len(fd) > 1 && fd[1] > 0 { 156 if len(fd) > 1 && fd[1] > 0 {
151 if ok, err := DuplicateHandle(currentProc, int32(fd[1]), current Proc, &startupInfo.StdOutput, 0, true, DUPLICATE_SAME_ACCESS); !ok { 157 if ok, err := DuplicateHandle(currentProc, int32(fd[1]), current Proc, &startupInfo.StdOutput, 0, true, DUPLICATE_SAME_ACCESS); !ok {
(...skipping 29 matching lines...) Expand all
181 handle = int(processInfo.Process) 187 handle = int(processInfo.Process)
182 CloseHandle(processInfo.Thread) 188 CloseHandle(processInfo.Thread)
183 } 189 }
184 return 190 return
185 } 191 }
186 192
187 // Ordinary exec. 193 // Ordinary exec.
188 func Exec(argv0 string, argv []string, envv []string) (err int) { 194 func Exec(argv0 string, argv []string, envv []string) (err int) {
189 return EWINDOWS 195 return EWINDOWS
190 } 196 }
LEFTRIGHT

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