diff --git a/signals.go b/signals.go index 153af4837..0138ad51f 100644 --- a/signals.go +++ b/signals.go @@ -37,6 +37,8 @@ func newSignalHandler() chan *signalHandler { switch sig := unix.Signal(i); sig { case unix.SIGCHLD: // Already set up above. + case unix.SIGTTIN, unix.SIGTTOU: + // Job control: use the default action (stop), see #1430. case unix.SIGURG: // SIGURG is used by the Go runtime for asynchronous // preemption, so runc receives it from time to time, diff --git a/tests/integration/run.bats b/tests/integration/run.bats index 34b3555c0..c8042b548 100644 --- a/tests/integration/run.bats +++ b/tests/integration/run.bats @@ -246,3 +246,28 @@ EOF # can not be removed, and the next test to use this name would fail. refute_output --partial "unable to destroy container" } + +@test "runc run [SIGTTIN and SIGTTOU are not caught]" { + update_config '.process.terminal = false | .process.args = ["sleep", "infinity"]' + + runc run test_busybox > ($1 - 1) & 1)) + } + retry 10 0.5 sig_caught 15 # SIGTERM + + # SIGTTIN and SIGTTOU should not be caught (and forwarded to the + # container), so runc in a background process group is stopped + # when accessing the terminal, see #1430. + run ! sig_caught 21 # SIGTTIN + run ! sig_caught 22 # SIGTTOU + + runc kill test_busybox KILL + wait "$pid" || true +}