This is an archive of the discontinued LLVM Phabricator instance.

MainLoop: avoid infinite loop when pty slave gets closed
ClosedPublic

Authored by labath on Dec 8 2017, 7:23 AM.

Details

Summary

For ptys (at least on Linux), the end-of-file (closing of the slave FD)
is signalled by the POLLHUP flag. We were ignoring this flag, which
meant that when this happened, we would spin in a loop, continuously
calling poll(2) and not making any progress.

This makes sure we treat POLLHUP as a read event (reading will return
0), and we call the registered callback when it happens. This is the
behavior our clients expect (and is consistent with how select(2)
works).

Diff Detail

Repository
rL LLVM

Event Timeline

labath created this revision.Dec 8 2017, 7:23 AM
davide accepted this revision.Dec 8 2017, 8:29 AM
davide added subscribers: jingham, davide.

LGTM. @jingham ? I'll try this change on macOS to make sure it won't break anything.

This revision is now accepted and ready to land.Dec 8 2017, 8:29 AM

Darwin uses a kqueue-based implementation of this, so it definitely won't *break* anything, although I'd appreciate it if you can check whether the test passes there. My cursory reading of the kqueue man page makes me believe it should not be affected by this.

eugene accepted this revision.Dec 8 2017, 1:25 PM
This revision was automatically updated to reflect the committed changes.