]> Cypherpunks repositories - gostls13.git/commitdiff
os: keep attr.Files alive when calling StartProcess
authorIan Lance Taylor <iant@golang.org>
Tue, 15 Oct 2019 14:52:23 +0000 (07:52 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 15 Oct 2019 20:34:04 +0000 (20:34 +0000)
Updates #34810
Fixes #34858

Change-Id: Ie934861e51eeafe8a7fd6653c4223a5f5d45efe8
Reviewed-on: https://go-review.googlesource.com/c/go/+/201198
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/os/exec_posix.go

index f6c7a49c1b3452f3273871da9857ffdd8a374b20..95ccc246a82110d5f835f6657c46c9cc80242a89 100644 (file)
@@ -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
 }