Why dup()?

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

 



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);

The remote session did close stdout.  The sshd from which it was spawned signaled to close stdout.  The ssh program received that signal and closed, well, something, but not stdout.  It closed a copy.  Importantly, it left a copy open, so my program got no EOF.

Why not:

        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?

Thanks,

David
_______________________________________________
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