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>
"io/ioutil"
"math/rand"
"os"
+ "os/signal"
"runtime"
"sync"
+ "syscall"
"testing"
"time"
)
// 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)