Interrupt reading () on signal

I have a stream that continuously reads a serial port for data. If the main program receives SIGINT, it calls g_thread_join () on the serial port stream.

However, since reading blocks the serial port stream, it will not return and run the program until I receive bytes on the serial line, and then it can exit.

Is there a way to pass SIGINT on for reading () so that it can be forcibly returned when the main thread requires it?

+3
source share
2 answers

() , select(2) . , SIGINT, , .

+3

read() EINTR, unset SA_RESTART sa_flags struct sigaction, sigaction() SIGINT.


read() . . : ?

+3

All Articles