I am working on a program that opens a master/slave pair to communicate between them. I need to wait until some process connects to the slave and starts sending data.
I have used the trick described in this answer to tell if the port is open or not by setting the HUP signal. I can check for the port to be open, but when I try to read I get read failed: [Errno 5] Input/output error
. Doing select does not block. I have tried epoll in the hope edge polling might work both when setting and unsetting a flag, but it works just the same.
Is there any way to block waiting for the HUP flag to become unset, which will happen if the port is open?