I am working on a small library for creating a pair of connected pts. I use an epoll fd
, in which I register the master fd
for two pseudo-terminals for EPOLLIN
events. When my example client program starts, the event loop is idle and so it is when two clients (microcom in my case) open each slave. But when any of the clients closes it's slave end, the epoll_wait
continuously reports EPOLLHUP
events for the slave's master.
In order to prevent this, I keep a file descriptor opened with O_WRONLY
on each slave, it works (no more EPOLLHUP
), but I think this is more a hack than a real solution...
Socat seems to use a busy wait with a small sleep in this situation.
I have tried to :
- use the Edge Triggered behavior
EPOLL_CTL_DEL
then re-add the master producing HUP's
None of these attempt has shown any result.
Is there way to clean up the "HUP state" and put back the master file descriptors to their state prior to their slave's opening, after an EPOLLHUP occurs ?