Why dup()?

David Newall
2017-10-13T12:21:04Z

> I did have a better example.

I do have a better example.

 ? ssh localhost 'exec cat > /dev/null 2>&1' | { read l; echo
${l:-EOF}; }

(Bonus points for seeing the irony.)

This should immediately print EOF.? It doesn't, because the duplicate
file descriptor on stdout prevents pipe closure until ssh exits.

Simply removing dup(), that is, saying "out = STDOUT_FILENO", results
in
correct behavior.? I think it's the right change.? I'll go further and
suggest that the same change should be made to err.? I would suggest it
should also be made to in, but that breaks tcsetattr on exit.