tags:

views:

46

answers:

2

What does sig in int pthread_kill(pthread_t thread, int sig) refer to? Are there predefined sigs? :S

+1  A: 

A little Google goes a long way:

http://opengroup.org/onlinepubs/007908775/xsh/signal.h.html

There's a table about 1/4th of the way down the page you might find handy.

KevenK
What if I want to use it to interrupt sleep()? SIGCONT doesn't seem to work.
lies
SIGCONT is, AFAIK, only used for terminal processes and only used in conjuction with SIGSTOP. You send SIGSTOP to stop the process, SIGCONT to tell it to continue. sleep will only be interrupted if a signal that is not ignored arrives; I would suspect if the process is not stopped, SIGCONT will be ignored. You could try SIGUSR1. Remember you also have to set up a signal handler in the thread that is running to catch whatever signal you want to use; otherwise a signal will typically terminate the process.
Jack Lloyd
What do you mean by "you also have to set up a signal handler in the thread that is running to catch whatever signal you want to use"? What does "a signal that is not ignored arrives mean"? How do I send a signal that is not ignored?
lies
+2  A: 

In reply to your comment about interrupting sleep: Instead of attempting to force signals to work here, have you considered instead of sleep using pthread_cond_timedwait instead? It lets you effectively sleep and provides a thread-safe mechanism to abort the sleep early via a pthread_cond_signal.

Mark B
I did consider it but I am trying to avoid using conditions, if that is possible.
lies
@return: That seems some strange reasoning: avoiding condition variables, but then resorting to signals, especially since you don't seem to be comfortable with signal-handlers. Any reasons why?
stefaanv