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

Delta Between Two Patch Sets: src/pkg/debug/proc/proc_linux.go

Issue 4253052: code review 4253052: os, syscall: add ProcAttributes type. Change StartProce... (Closed)
Left Patch Set: 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:
Right: Side by side diff | Download
« no previous file with change/comment | « src/cmd/godoc/main.go ('k') | src/pkg/exec/exec.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
(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 package proc 5 package proc
6 6
7 // TODO(rsc): Imports here after to be in proc.go too in order 7 // TODO(rsc): Imports here after to be in proc.go too in order
8 // for deps.bash to get the right answer. 8 // for deps.bash to get the right answer.
9 import ( 9 import (
10 "container/vector" 10 "container/vector"
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 if err != nil { 1272 if err != nil {
1273 p.Detach() 1273 p.Detach()
1274 // TODO(austin) Detach stopped the monitor already 1274 // TODO(austin) Detach stopped the monitor already
1275 //p.stopMonitor(err); 1275 //p.stopMonitor(err);
1276 return nil, err 1276 return nil, err
1277 } 1277 }
1278 1278
1279 return p, nil 1279 return p, nil
1280 } 1280 }
1281 1281
1282 // ForkExec forks the current process and execs argv0, stopping the 1282 // StartProcess forks the current process and execs argv0, stopping the
1283 // new process after the exec syscall. See os.ForkExec for additional 1283 // new process after the exec syscall. See os.StartProcess for additional
1284 // details. 1284 // details.
1285 func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*os.F ile) (Process, os.Error) { 1285 func StartProcess(argv0 string, argv []string, attr *os.ProcAttr) (Process, os.E rror) {
1286 » sysattr := &syscall.ProcAttr{
1287 » » Dir: attr.Dir,
1288 » » Env: attr.Env,
1289 » » Ptrace: true,
1290 » }
1286 p := newProcess(-1) 1291 p := newProcess(-1)
1287 1292
1288 // Create array of integer (system) fds. 1293 // Create array of integer (system) fds.
1289 » intfd := make([]int, len(fd)) 1294 » intfd := make([]int, len(attr.Files))
1290 » for i, f := range fd { 1295 » for i, f := range attr.Files {
1291 if f == nil { 1296 if f == nil {
1292 intfd[i] = -1 1297 intfd[i] = -1
1293 } else { 1298 } else {
1294 intfd[i] = f.Fd() 1299 intfd[i] = f.Fd()
1295 } 1300 }
1296 } 1301 }
1302 sysattr.Files = intfd
1297 1303
1298 // Fork from the monitor thread so we get the right tracer pid. 1304 // Fork from the monitor thread so we get the right tracer pid.
1299 err := p.do(func() os.Error { 1305 err := p.do(func() os.Error {
1300 » » pid, errno := syscall.PtraceForkExec(argv0, argv, envv, dir, int fd) 1306 » » pid, _, errno := syscall.StartProcess(argv0, argv, sysattr)
1301 if errno != 0 { 1307 if errno != 0 {
1302 return &os.PathError{"fork/exec", argv0, os.Errno(errno) } 1308 return &os.PathError{"fork/exec", argv0, os.Errno(errno) }
1303 } 1309 }
1304 p.pid = pid 1310 p.pid = pid
1305 1311
1306 // The process will raise SIGTRAP when it reaches execve. 1312 // The process will raise SIGTRAP when it reaches execve.
1307 _, err := p.newThread(pid, syscall.SIGTRAP, false) 1313 _, err := p.newThread(pid, syscall.SIGTRAP, false)
1308 return err 1314 return err
1309 }) 1315 })
1310 if err != nil { 1316 if err != nil {
1311 p.stopMonitor(err) 1317 p.stopMonitor(err)
1312 return nil, err 1318 return nil, err
1313 } 1319 }
1314 1320
1315 return p, nil 1321 return p, nil
1316 } 1322 }
LEFTRIGHT

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