Thread specific signal handling - Unix

This is a discussion on Thread specific signal handling - Unix ; Is there any way to set up a signal handler for specific threads, instead of for the whole process using sigaction()? This is for Solaris and Linux. I've noticed some other code using calls to sigemptyset() and pthread_sigmask(), but these ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Thread specific signal handling

  1. Thread specific signal handling

    Is there any way to set up a signal handler for specific threads,
    instead of for the whole process using sigaction()? This is for
    Solaris and Linux. I've noticed some other code using calls to
    sigemptyset() and pthread_sigmask(), but these just seem to allow
    changing the inherited signal mask; there's nothing about setting up a
    thread specific handler (that I've found so far anyway).

  2. Re: Thread specific signal handling

    kenkahn writes:
    > Is there any way to set up a signal handler for specific threads,
    > instead of for the whole process using sigaction()?


    Not using any of the standardized threading interfaces. There are two
    categories of signal defined:

    - so-called asychronous signals targetted at the process (eg
    SIGCHLD or SIGALRM): These are supposed to be handled by an
    arbitrary thread not blocking them (presumably, one that
    isn't already busy doing something else)

    - synchronous signals (eg SIGSEGV), which are supposed to be
    sent to the thread which caused them

    It is possible to send signals to specific threads using pthread_kill,
    but not to defined per-thread handlers for any signals (eg that one
    thread does something different upon reception of a SIGUSR1 than
    another).



+ Reply to Thread