I have a pthread that runs in a loop, calling accept() in a blocking manner. Is there any way to interrupt that call from another thread? Everything points to sending the thread a signal, but apparently you can only send a process a signal.
I can’t just kill the thread because then it leaves the socket open. And that’s not very clean anyway. Is there really no way to do this?
You can signal a thread using
pthread_kill(3).Note, you don’t have to kill the thread; you can send a signal that simply makes
acceptfail withEINTR.