Re: Why dup()?

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



On Tue, 10 Oct 2017, David Newall wrote:

> Hello all,
> 
> My scripts, which read stdout from ssh, weren't seeing EOF from the 
> remote session.  It was being sent, but lost.  I tracked it down to the 
> following code, in ssh.c, at ssh_session2_open:
> 
>          if (stdin_null_flag) {
>                  in = open(_PATH_DEVNULL, O_RDONLY);
>          } else {
>                  in = dup(STDIN_FILENO);
>          }
>          out = dup(STDOUT_FILENO);
>          err = dup(STDERR_FILENO);

This is probably because some things interact with stderr (and possibly
stdout) separately than through the channels layer.

>          if (stdin_null_flag) {
>                  in = open(_PATH_DEVNULL, O_RDONLY);
>          } else {
>                  in = STDIN_FILENO;
>          }
>          out = STDOUT_FILENO;
>          err = STDERR_FILENO;
> 
> If not that, how is a program that reads from ssh's output ever going to 
> see EOF?

I don't think communicating closes on stdout separately to ssh itself
terminating is a case we've considered supporting before. Maybe we
could, but there are bound to be some subtleties beyond your suggested
solution.

At a minimum, I think we'd have to dup2 a fd to /dev/null to
STDOUT_FILENO so writes to stdout (e.g. from ill-behaved libraries) have
somewhere to go. I think we'd want to leave stderr the way it is too.

-d
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev




[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux