Trying to interrupt a blocking read...

Joel Sherrill joel at
Tue Sep 10 17:18:51 UTC 2019

On Tue, Sep 10, 2019 at 12:09 AM Benjamin Ellsworth
<2gigspambucket at> wrote:
> 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).

What version? I thought select() on termios devices was added at least
to the master.

You are right that it historically hasn't worked.

pipe() is supported. psxpipe01 is the test. Not sure about the use case
you have in mind.

> 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.

read() on a UART should be able to do non-blocking or timeout on read()
with the VMIN and VTIME support from termios. There should be examples
of this around the net.

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

> Thanks.
> _______________________________________________
> devel mailing list
> devel at

More information about the devel mailing list