Skip to content

Commit

Permalink
closing subscribers FDs when wrapping input is exhaused
Browse files Browse the repository at this point in the history
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
miki725 committed Feb 15, 2024
1 parent 30324eb commit 4536ae1
Show file tree
Hide file tree
Showing 3 changed files with 734 additions and 706 deletions.
Loading

0 comments on commit 4536ae1

Please sign in to comment.