mirror of
https://github.com/golang/go
synced 2024-11-25 06:57:58 -07:00
os: diagnose chdir error during StartProcess
R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5711044
This commit is contained in:
parent
b47cef394b
commit
7aba72baaa
@ -18,6 +18,16 @@ import (
|
||||
//
|
||||
// If there is an error, it will be of type *PathError.
|
||||
func StartProcess(name string, argv []string, attr *ProcAttr) (p *Process, err error) {
|
||||
// Double-check existence of the directory we want
|
||||
// to chdir into. We can make the error clearer this way.
|
||||
if attr != nil && attr.Dir != "" {
|
||||
if _, err := Stat(attr.Dir); err != nil {
|
||||
pe := err.(*PathError)
|
||||
pe.Op = "chdir"
|
||||
return nil, pe
|
||||
}
|
||||
}
|
||||
|
||||
sysattr := &syscall.ProcAttr{
|
||||
Dir: attr.Dir,
|
||||
Env: attr.Env,
|
||||
|
Loading…
Reference in New Issue
Block a user