Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closing subscribers FDs when wrapping input is exhaused
the issue we are trying to solve is: ``` echo foo | bar --stdin ``` If bar is reading its input from stdin, stdin needs to close so that bar can proceed. If stdin is not closed, bar is hang waiting for the stdin. In libc if stdin is closed we get a `read()` output of 0 after a read which returned some data: ``` read("foo\n") -> 4 read("") -> 0 // as stdin closed ``` if the stdin is not closed, the second read will hang forever as it will wait for the stdin to close What the fix does here is that when it sees a read() returning 0 it passes that indication to all the subscribers to let them know that the write FD should be closed to mimick what we got on the input side of the switchboard. Also it fixes some mixed whitespace as things werent rendering well in vim.
- Loading branch information