I have a C++ thread (Linux) that uses blocking read to get data on some IO interface. I want to be able to abort read, and exit the thread.
Here https://stackoverflow.com/a/51742996/16317303 the general principle is explained, using pthread_kill to send a signal to a specific thread that interrupts the blocking read.
However, when I implement it that way, I am missing the "sending signal to specific thread" part. For example, CTRL+C in terminal does trigger the same handler as pthread_kill
does, meaning that CTRL+C is not ending the console application anymore. For me it seems like a global handler for any SIGINT, and I don't know how I can make it that way that only this specific thread receives the signal and takes action, otherwise, when I use this pattern for different threads, I can't distinguish which thread receives a signal.