Skip to content

Commit

Permalink
os: keep attr.Files alive when calling StartProcess
Browse files Browse the repository at this point in the history
Updates #34810
Fixes #34858

Change-Id: Ie934861e51eeafe8a7fd6653c4223a5f5d45efe8
Reviewed-on: https://go-review.googlesource.com/c/go/+/201198
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
  • Loading branch information
ianlancetaylor committed Oct 15, 2019
1 parent 831e3cf commit 52e5987
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/os/exec_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package os

import (
"runtime"
"syscall"
)

Expand Down Expand Up @@ -49,9 +50,14 @@ func startProcess(name string, argv []string, attr *ProcAttr) (p *Process, err e
}

pid, h, e := syscall.StartProcess(name, argv, sysattr)

// Make sure we don't run the finalizers of attr.Files.
runtime.KeepAlive(attr)

if e != nil {
return nil, &PathError{"fork/exec", name, e}
}

return newProcess(pid, h), nil
}

Expand Down

0 comments on commit 52e5987

Please sign in to comment.