Restoring block mode on exiting

Dmitry Belyavskiy dbelyavs at
Fri Apr 23 01:36:21 AEST 2021


OpenSSH incorrectly restores the standard mode (blocking mode) on standard
output upon exiting. This causes the next shell scripts commands to
potentially fail in EAGAIN.
The reproducer is:

ssh localhost true
cat /dev/zero
) | sleep 30

Restoring the blocking modes happens with the duped file descriptors and
too late.

The changes causing this problem was introduced in

The 2 possible fixes can be found in (adhoc patch) and (more robust one).

I think it's worth fixing the issue in this, that or any other way.
I'll be happy to adopt any of those patches to the state when they become
suitable for upstream.

Many thanks in advance!

Dmitry Belyavskiy

More information about the openssh-unix-dev mailing list