]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: ignore EAGAIN from exec in TestCgoExecSignalMask
authorIan Lance Taylor <iant@golang.org>
Tue, 18 Sep 2018 14:58:11 +0000 (07:58 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 18 Sep 2018 15:16:14 +0000 (15:16 +0000)
Fixes #27731

Change-Id: Ifb4d57923b1bba0210ec1f623d779d7b5f442812
Reviewed-on: https://go-review.googlesource.com/135995
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/testdata/testprogcgo/exec.go

index 2e948401c87a5301b198da118d1ba1a9af86615a..94da5dc526bc2d074aa491d0447930d74307fe3e 100644 (file)
@@ -75,6 +75,14 @@ func CgoExecSignalMask() {
                                        cmd.Stdout = os.Stdout
                                        cmd.Stderr = os.Stderr
                                        if err := cmd.Run(); err != nil {
+                                               // An overloaded system
+                                               // may fail with EAGAIN.
+                                               // This doesn't tell us
+                                               // anything useful; ignore it.
+                                               // Issue #27731.
+                                               if isEAGAIN(err) {
+                                                       return
+                                               }
                                                fmt.Printf("iteration %d: %v\n", j, err)
                                                os.Exit(1)
                                        }
@@ -87,3 +95,11 @@ func CgoExecSignalMask() {
 
        fmt.Println("OK")
 }
+
+// isEAGAIN reports whether err is an EAGAIN error from a process execution.
+func isEAGAIN(err error) bool {
+       if p, ok := err.(*os.PathError); ok {
+               err = p.Err
+       }
+       return err == syscall.EAGAIN
+}