aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2019-10-15 07:52:23 -0700
committerIan Lance Taylor <iant@golang.org>2019-10-15 20:34:04 +0000
commit52e5987f5d92f707411359d9f56cb0cec97ac167 (patch)
treee508abb8c478e711e533e6dd50af53e4b8bf80bd /src
parent831e3cfaa594ceb70c3cbeff2d31fddcd9a25a5e (diff)
downloadgo-52e5987f5d92f707411359d9f56cb0cec97ac167.tar.xz
os: keep attr.Files alive when calling StartProcess
Updates #34810 Fixes #34858 Change-Id: Ie934861e51eeafe8a7fd6653c4223a5f5d45efe8 Reviewed-on: https://go-review.googlesource.com/c/go/+/201198 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/os/exec_posix.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/os/exec_posix.go b/src/os/exec_posix.go
index f6c7a49c1b..95ccc246a8 100644
--- a/src/os/exec_posix.go
+++ b/src/os/exec_posix.go
@@ -7,6 +7,7 @@
package os
import (
+ "runtime"
"syscall"
)
@@ -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
}