tailscale/tempfork/osexec
Josh Bleecher Snyder 585a0d8997 all: use testing.T.TempDir
Bit of Friday cleanup.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2020-10-02 20:31:31 -07:00
..
README.md Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
bench_test.go Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
env_test.go Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
example_test.go Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
exec.go Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
exec_unix.go Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
exec_windows.go Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
internal_test.go Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
lp_js.go Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
lp_plan9.go Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
lp_test.go Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
lp_unix.go Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
lp_unix_test.go all: use testing.T.TempDir 2020-10-02 20:31:31 -07:00
lp_windows.go Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00

README.md

This is a temporary fork of Go 1.13's os/exec package, to work around https://github.com/golang/go/issues/36644.

The main modification (outside of removing some tests that require internal-only packages to run) is:

commit 3c66be240f1ee1f1b5f03bed79eb0d9f8c08965a
Author: Avery Pennarun <apenwarr@gmail.com>
Date:   Sun Jan 19 03:17:30 2020 -0500

Cmd.Wait(): handle EINTR return code from os.Process.Wait().

This is probably not actually the correct fix; most likely
os.Process.Wait() itself should be fixed to retry on EINTR so that it
never leaks out of that function. But if we're going to patch a
particular module, it's safer to patch a higher-level one like os/exec
rather than the os module itself.

diff --git a/exec.go b/exec.go
index 17ef003e..5375e673 100644
--- a/exec.go
+++ b/exec.go
@@ -498,7 +498,21 @@ func (c *Cmd) Wait() error {
        }
                c.finished = true

-       state, err := c.Process.Wait()
+       var err error
+       var state *os.ProcessState
+       for {
+               state, err = c.Process.Wait()
+               if err != nil {
+                       xe, ok := err.(*os.SyscallError)
+                       if ok {
+                               if xe.Unwrap() == syscall.EINTR {
+                                       // temporary error, retry wait syscall
+                                       continue
+                               }
+                       }
+               }
+               break
+       }
        if c.waitDone != nil {
                        close(c.waitDone)
                                }