Trying to interrupt a blocking read...

Benjamin Ellsworth 2GigSpamBucket at gmail.com
Tue Sep 10 21:59:18 UTC 2019


Joel,

Thanks for responding.

Our vendor's development kit uses a variant of 4.11.

It doesn't look like pipes work with the select call, and again there 
are dire warnings in the select.h file about how it's not really a good 
function to use anyway.

I'll look at VMIN and VTIME.  Thank you very much for the pointer.

Thanks,
--Ben


On 10-Sep-19 10:18 AM, Joel Sherrill wrote:
> On Tue, Sep 10, 2019 at 12:09 AM Benjamin Ellsworth
> <2gigspambucket at gmail.com> 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.
>
> --joel
>>
>>
>> Thanks.
>>
>> _______________________________________________
>> devel mailing list
>> devel at rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
>




More information about the devel mailing list