Skip to content

Commit

Permalink
syscall: return error instead of panicking in windows StartProcess
Browse files Browse the repository at this point in the history
Fixes golang#11417

Change-Id: Iacea829a48b39df0a4f751b06b19e918fbb713d0
Reviewed-on: https://go-review.googlesource.com/11604
Reviewed-by: Rob Pike <[email protected]>
  • Loading branch information
alexbrainman committed Jun 29, 2015
1 parent 214c7a2 commit 0bafe0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/os/os_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,12 @@ func TestStatJunctionLink(t *testing.T) {
t.Fatalf("link should point to %v but points to %v instead", expected, got)
}
}

func TestStartProcessAttr(t *testing.T) {
p, err := os.StartProcess(os.Getenv("COMSPEC"), []string{"/c", "cd"}, new(os.ProcAttr))
if err != nil {
return
}
defer p.Wait()
t.Fatalf("StartProcess expected to fail, but succeeded.")
}
3 changes: 3 additions & 0 deletions src/syscall/exec_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
if len(attr.Files) > 3 {
return 0, 0, EWINDOWS
}
if len(attr.Files) < 3 {
return 0, 0, EINVAL
}

if len(attr.Dir) != 0 {
// StartProcess assumes that argv0 is relative to attr.Dir,
Expand Down

0 comments on commit 0bafe0e

Please sign in to comment.