Commit 52e5987f authored by Ian Lance Taylor's avatar Ian Lance Taylor

os: keep attr.Files alive when calling StartProcess

Updates #34810
Fixes #34858

Change-Id: Ie934861e51eeafe8a7fd6653c4223a5f5d45efe8
Reviewed-on: https://go-review.googlesource.com/c/go/+/201198Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent 831e3cfa
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
package os package os
import ( import (
"runtime"
"syscall" "syscall"
) )
...@@ -49,9 +50,14 @@ func startProcess(name string, argv []string, attr *ProcAttr) (p *Process, err e ...@@ -49,9 +50,14 @@ func startProcess(name string, argv []string, attr *ProcAttr) (p *Process, err e
} }
pid, h, e := syscall.StartProcess(name, argv, sysattr) 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 { if e != nil {
return nil, &PathError{"fork/exec", name, e} return nil, &PathError{"fork/exec", name, e}
} }
return newProcess(pid, h), nil return newProcess(pid, h), nil
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment