Interrupt read() on signal
c, linux, multithreading, posix, signals
Solution
The accepted answer for this previous question on implementing timeout for read() when reading from a serial port shows how to use `select(2)` to perform reading with timeout. The SIGINT signal you send will thus be eventually acted upon.
Problem
I have a thread that continuously reads a serial port for data. If the main program receives a SIGINT it calls g_thread_join() on the serial port thread. However, since the read is blocking the serial port thread won't return and program stalls untill i get a byte on the serial line and then it can exit. Is there a way to pass the SIGINT on to read() so that it can be forced to return when the main thread demands it?