In our server code we are using poll() system call for monitoring client sockets. The poll() is called with a large timeout value. So the thread calling poll() gets blocked for I/O.
As per the flow, we have a scenario where we need to terminate thread that blocked in poll() from a different thread. I have came across pthread_kill() and pthread_cancel() functions, which can terminate the target thread blocked for I/O.
By reading the man pages, both these functions seems to work fine. Few links on internet suggested that both of these functions are dangerous to use.
Is there any alternative way to terminate the thread blocked for I/O ? If not, which of these functions is recommended to use.