> I would send the signal by doing something like this:
> pthread_t threadId_;
> pthread_kill( threadId_, SIGKILL );
>
> (Kill actually kills my entire process not just the target thread).
>
> Any ideas on the signal to use?
Hhmm...threads should be separate processes, so I didn't think it would
affect the signalling thread. Still, SIGKILL can't be
blocked/ignored/handled, so you shouldn't be using that anyhow.
You could try using signal() and setting up a do-nothing signal handler
for each thread when it first starts executing. After that, SIGALRM is
probably a good candidate. (Hypothetically, you could just have the thread
call alarm() before the blocking recv(), and if you get the signal, see if
it's time to shutdown, otherwise, reset the alarm() and go back to recv()
again...that may or may not be less ugly, depending on what your design
looks like.
If this is all too hackish for you, you could consider using select() with
the socket and polling for new data before calling recv(), which
will also avoid the blocking behaviour.
--ryan.
|