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

Side by Side Diff: src/pkg/syscall/exec_unix.go

Issue 4602054: code review 4602054: sort: change IntArray etc. to IntSlice for better name ... (Closed)
Patch Set: diff -r d9d02c38ddc2 https://go.googlecode.com/hg/ Created 13 years, 9 months 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:
View unified diff | Download patch
« no previous file with comments | « src/pkg/syscall/exec_plan9.go ('k') | src/pkg/unicode/maketables.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // 4) Open. Can block. Use O_CLOEXEC if available (Linux). 55 // 4) Open. Can block. Use O_CLOEXEC if available (Linux).
56 // Otherwise, live with the race. 56 // Otherwise, live with the race.
57 // 5) Dup. Does not block. Use the ForkLock. 57 // 5) Dup. Does not block. Use the ForkLock.
58 // On Linux, could use fcntl F_DUPFD_CLOEXEC 58 // On Linux, could use fcntl F_DUPFD_CLOEXEC
59 // instead of the ForkLock, but only for dup(fd, -1). 59 // instead of the ForkLock, but only for dup(fd, -1).
60 60
61 var ForkLock sync.RWMutex 61 var ForkLock sync.RWMutex
62 62
63 // Convert array of string to array 63 // Convert array of string to array
64 // of NUL-terminated byte pointer. 64 // of NUL-terminated byte pointer.
65 func StringArrayPtr(ss []string) []*byte { 65 func StringSlicePtr(ss []string) []*byte {
66 bb := make([]*byte, len(ss)+1) 66 bb := make([]*byte, len(ss)+1)
67 for i := 0; i < len(ss); i++ { 67 for i := 0; i < len(ss); i++ {
68 bb[i] = StringBytePtr(ss[i]) 68 bb[i] = StringBytePtr(ss[i])
69 } 69 }
70 bb[len(ss)] = nil 70 bb[len(ss)] = nil
71 return bb 71 return bb
72 } 72 }
73 73
74 func CloseOnExec(fd int) { fcntl(fd, F_SETFD, FD_CLOEXEC) } 74 func CloseOnExec(fd int) { fcntl(fd, F_SETFD, FD_CLOEXEC) }
75 75
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 286
287 if attr == nil { 287 if attr == nil {
288 attr = &zeroAttributes 288 attr = &zeroAttributes
289 } 289 }
290 290
291 p[0] = -1 291 p[0] = -1
292 p[1] = -1 292 p[1] = -1
293 293
294 // Convert args to C form. 294 // Convert args to C form.
295 argv0p := StringBytePtr(argv0) 295 argv0p := StringBytePtr(argv0)
296 » argvp := StringArrayPtr(argv) 296 » argvp := StringSlicePtr(argv)
297 » envvp := StringArrayPtr(attr.Env) 297 » envvp := StringSlicePtr(attr.Env)
298 298
299 if OS == "freebsd" && len(argv[0]) > len(argv0) { 299 if OS == "freebsd" && len(argv[0]) > len(argv0) {
300 argvp[0] = argv0p 300 argvp[0] = argv0p
301 } 301 }
302 302
303 var chroot *byte 303 var chroot *byte
304 if attr.Chroot != "" { 304 if attr.Chroot != "" {
305 chroot = StringBytePtr(attr.Chroot) 305 chroot = StringBytePtr(attr.Chroot)
306 } 306 }
307 var dir *byte 307 var dir *byte
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 // StartProcess wraps ForkExec for package os. 371 // StartProcess wraps ForkExec for package os.
372 func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid, handle int, err int) { 372 func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid, handle int, err int) {
373 pid, err = forkExec(argv0, argv, attr) 373 pid, err = forkExec(argv0, argv, attr)
374 return pid, 0, err 374 return pid, 0, err
375 } 375 }
376 376
377 // Ordinary exec. 377 // Ordinary exec.
378 func Exec(argv0 string, argv []string, envv []string) (err int) { 378 func Exec(argv0 string, argv []string, envv []string) (err int) {
379 _, _, err1 := RawSyscall(SYS_EXECVE, 379 _, _, err1 := RawSyscall(SYS_EXECVE,
380 uintptr(unsafe.Pointer(StringBytePtr(argv0))), 380 uintptr(unsafe.Pointer(StringBytePtr(argv0))),
381 » » uintptr(unsafe.Pointer(&StringArrayPtr(argv)[0])), 381 » » uintptr(unsafe.Pointer(&StringSlicePtr(argv)[0])),
382 » » uintptr(unsafe.Pointer(&StringArrayPtr(envv)[0]))) 382 » » uintptr(unsafe.Pointer(&StringSlicePtr(envv)[0])))
383 return int(err1) 383 return int(err1)
384 } 384 }
OLDNEW
« no previous file with comments | « src/pkg/syscall/exec_plan9.go ('k') | src/pkg/unicode/maketables.go » ('j') | no next file with comments »

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