]> Cypherpunks repositories - gostls13.git/commitdiff
os: ignore SIGTTIN during TestTTYClose
authorIan Lance Taylor <iant@golang.org>
Thu, 20 Sep 2018 03:09:02 +0000 (20:09 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 18 Oct 2018 00:08:57 +0000 (00:08 +0000)
Otherwise, if the test is run in the background, it will stop waiting
for access to the terminal.

Change-Id: Ib5224c6cb9060281e05c3b00cd2964445421e774
Reviewed-on: https://go-review.googlesource.com/c/136415
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/os/timeout_test.go

index 1886accb55f7c6c70c6296c28ec0ad4263ac5599..4720738d247878f01680e2fbaf991108a24f0964 100644 (file)
@@ -16,8 +16,10 @@ import (
        "io/ioutil"
        "math/rand"
        "os"
+       "os/signal"
        "runtime"
        "sync"
+       "syscall"
        "testing"
        "time"
 )
@@ -591,6 +593,10 @@ func TestRacyWrite(t *testing.T) {
 
 // Closing a TTY while reading from it should not hang.  Issue 23943.
 func TestTTYClose(t *testing.T) {
+       // Ignore SIGTTIN in case we are running in the background.
+       signal.Ignore(syscall.SIGTTIN)
+       defer signal.Reset(syscall.SIGTTIN)
+
        f, err := os.Open("/dev/tty")
        if err != nil {
                t.Skipf("skipping because opening /dev/tty failed: %v", err)