openssh 2.9p1: data loss when stdout sent to a pipe
Markus Friedl
Markus.Friedl at informatik.uni-erlangen.de
Sat Jun 16 06:17:19 EST 2001
On Fri, Jun 15, 2001 at 02:19:44PM -0400, Philip Spencer wrote:
> --- openssh-2.9p1/clientloop.c.losesdata Fri Apr 20 08:50:51 2001
> +++ openssh-2.9p1/clientloop.c Fri Jun 15 14:13:32 2001
> @@ -787,12 +787,15 @@
>
> if (!compat20) {
> /* enable nonblocking unless tty */
> + /* REMOVED for now since it prevents ssh command output from
> + being reliably sent to a pipe. - PHS 2001/06/15
> if (!isatty(fileno(stdin)))
> set_nonblock(fileno(stdin));
> if (!isatty(fileno(stdout)))
> set_nonblock(fileno(stdout));
> if (!isatty(fileno(stderr)))
> set_nonblock(fileno(stderr));
> + */
> max_fd = MAX(max_fd, fileno(stdin));
> max_fd = MAX(max_fd, fileno(stdout));
> max_fd = MAX(max_fd, fileno(stderr));
>
> Now, presumably those lines were added to the source code to address some
> other problem (perhaps one of the hanging problems I see mentioned on the
> list?) So simply removing them as per my patch above, while it works fine
> on our site, probably isn't the optimal solution.
we now do this (in -current):
/* restore blocking io */
if (!isatty(fileno(stdin)))
unset_nonblock(fileno(stdin));
if (!isatty(fileno(stdout)))
unset_nonblock(fileno(stdout));
if (!isatty(fileno(stderr)))
unset_nonblock(fileno(stderr));
before flushing stdout/stderr.
-m
More information about the openssh-unix-dev
mailing list