Trying to interrupt a blocking read...

Benjamin Ellsworth 2gigspambucket at gmail.com
Tue Sep 10 05:09:47 UTC 2019


Hello,

The code I'm working with currently does a read() on a device that has 
been opened with an open() call (a UART if that matters).  It nicely 
blocks waiting for a character (potentially forever).

I now need that read to be interrupted...  I looked for pselect() so it 
can block until I tell it to stop (via signal from another thread), but 
that doesn't seem to be supported.  I looked at the classic work-around 
using a pipe in a select call, but pipe() isn't supported and select 
apparently only works on sockets (and the comments in the select header 
make it sound like even that is a bad idea).

I can probably make things work with timeouts--basically making it into 
a polling loop, but I can't see a way to make the read timeout.  I dug 
down into the rtems read functions, but didn't see any way to make them 
timeout, nor did I see a way to cleanly interrupt them.

If anyone has any suggestions/ideas/pointers, I'd appreciate them.


Thanks.



More information about the devel mailing list