LEFT | RIGHT |
(no file at all) | |
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" |
| 11 "unsafe" |
11 "utf16" | 12 "utf16" |
12 ) | 13 ) |
13 | 14 |
14 var ForkLock sync.RWMutex | 15 var ForkLock sync.RWMutex |
15 | 16 |
16 // escape rewrites command line argument s as prescribed | 17 // escape rewrites command line argument s as prescribed |
17 // in http://msdn.microsoft.com/en-us/library/ms880421. | 18 // in http://msdn.microsoft.com/en-us/library/ms880421. |
18 // This function returns "" (2 double quotes) if s is empty. | 19 // This function returns "" (2 double quotes) if s is empty. |
19 // Alternatively, these transformations are done: | 20 // Alternatively, these transformations are done: |
20 // - every back slash (\) is doubled, but only if immediately | 21 // - every back slash (\) is doubled, but only if immediately |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 for i := range attr.Files { | 273 for i := range attr.Files { |
273 if attr.Files[i] > 0 { | 274 if attr.Files[i] > 0 { |
274 err := DuplicateHandle(p, int32(attr.Files[i]), p, &fd[i
], 0, true, DUPLICATE_SAME_ACCESS) | 275 err := DuplicateHandle(p, int32(attr.Files[i]), p, &fd[i
], 0, true, DUPLICATE_SAME_ACCESS) |
275 if err != 0 { | 276 if err != 0 { |
276 return 0, 0, err | 277 return 0, 0, err |
277 } | 278 } |
278 defer CloseHandle(int32(fd[i])) | 279 defer CloseHandle(int32(fd[i])) |
279 } | 280 } |
280 } | 281 } |
281 si := new(StartupInfo) | 282 si := new(StartupInfo) |
282 » GetStartupInfo(si) | 283 » si.Cb = uint32(unsafe.Sizeof(*si)) |
283 si.Flags = STARTF_USESTDHANDLES | 284 si.Flags = STARTF_USESTDHANDLES |
284 si.StdInput = fd[0] | 285 si.StdInput = fd[0] |
285 si.StdOutput = fd[1] | 286 si.StdOutput = fd[1] |
286 si.StdErr = fd[2] | 287 si.StdErr = fd[2] |
287 | 288 |
288 pi := new(ProcessInformation) | 289 pi := new(ProcessInformation) |
289 | 290 |
290 err = CreateProcess(argv0p, argvp, nil, nil, true, CREATE_UNICODE_ENVIRO
NMENT, createEnvBlock(attr.Env), dirp, si, pi) | 291 err = CreateProcess(argv0p, argvp, nil, nil, true, CREATE_UNICODE_ENVIRO
NMENT, createEnvBlock(attr.Env), dirp, si, pi) |
291 if err != 0 { | 292 if err != 0 { |
292 return 0, 0, err | 293 return 0, 0, err |
293 } | 294 } |
294 defer CloseHandle(pi.Thread) | 295 defer CloseHandle(pi.Thread) |
295 | 296 |
296 return int(pi.ProcessId), int(pi.Process), 0 | 297 return int(pi.ProcessId), int(pi.Process), 0 |
297 } | 298 } |
298 | 299 |
299 func Exec(argv0 string, argv []string, envv []string) (err int) { | 300 func Exec(argv0 string, argv []string, envv []string) (err int) { |
300 return EWINDOWS | 301 return EWINDOWS |
301 } | 302 } |
LEFT | RIGHT |