Why dup()?

Clark Wang dearvoid at gmail.com
Fri Oct 13 20:15:48 AEDT 2017


On Fri, Oct 13, 2017 at 4:20 PM, David Newall <openssh at davidnewall.com>
wrote:

> On 13/10/17 18:40, Clark Wang wrote:
>
>> On Fri, Oct 13, 2017 at 3:24 PM, David Newall <openssh at davidnewall.com
>> <mailto:openssh at davidnewall.com>> wrote:
>>
>>
>>        ssh localhost 'exec cat > /dev/null' | { read l; echo ${l:-EOF}; }
>>
>>     One should see "EOF" immediately (for values of immediate that
>>     include startup latency), but that's not what happens.
>>
>>
>> The ssh is still alive since the remote cat is waiting for input so the
>> read would not see EOF. Did you actually mean 'exec cat < /dev/null'?
>>
>>
> The ssh is still alive since the remote cat is waiting for input. That has
> zero relevance to EOF.  If you still don't get it, please replace "ssh
> localhost" with "sh -c" and see what should happen.
>

Tried with strace and see it closed fd 1 before exec. Thanks.


More information about the openssh-unix-dev mailing list