Skip to content

Commit 10b175c

Browse files
committed
signal: ignore tty.resize errors
Fixes a race that occurred very frequently in testing where the tty of the container may be closed by the time that runc gets to sending SIGWINCH. This failure mode is not fatal, but it would cause test failures due to expected outputs not matching. On further review it appears that the original addition of these checks in 4c5bf64 ("Check error return values") was actually not necessary, so partially revert that change. The particular failure mode this resolves would manifest as error logs of the form: time="2017-08-24T07:59:50Z" level=error msg="bad file descriptor" Fixes: 4c5bf64 ("Check error return values") Signed-off-by: Aleksa Sarai <[email protected]>
1 parent 1c81e2a commit 10b175c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

signals.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,15 @@ func (h *signalHandler) forward(process *libcontainer.Process, tty *tty, detach
7474
}
7575
}
7676

77-
// perform the initial tty resize.
78-
if err := tty.resize(); err != nil {
79-
logrus.Error(err)
80-
}
77+
// Perform the initial tty resize. Always ignore errors resizing because
78+
// stdout might have disappeared (due to races with when SIGHUP is sent).
79+
_ = tty.resize()
80+
// Handle and forward signals.
8181
for s := range h.signals {
8282
switch s {
8383
case unix.SIGWINCH:
84-
if err := tty.resize(); err != nil {
85-
logrus.Error(err)
86-
}
84+
// Ignore errors resizing, as above.
85+
_ = tty.resize()
8786
case unix.SIGCHLD:
8887
exits, err := h.reap()
8988
if err != nil {

0 commit comments

Comments
 (0)