From 361cf4a8805051ac3b8829fbcd9d64a0d2f50a71 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 19 Sep 2018 20:09:02 -0700 Subject: [PATCH] os: ignore SIGTTIN during TestTTYClose 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 TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/os/timeout_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/os/timeout_test.go b/src/os/timeout_test.go index 1886accb55..4720738d24 100644 --- a/src/os/timeout_test.go +++ b/src/os/timeout_test.go @@ -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) -- 2.50.0