About signal handler install info

naveen yadav yad.naveen at gmail.com
Thu Dec 1 05:03:53 EST 2011


Dear All,

I want to know is there any method/API  to know whether there is
previous signal handler for specific signal no.

Example:

In below case  we install 3 handler. So my question is if before
calling signal (SIGUSR1, handler2); is there any way i can get info
that there is "handler1" already install with SIGUSR1.

        signal (SIGUSR1, handler1);
        signal (SIGUSR1, handler2);
        signal (SIGUSR1, handler3);

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <signal.h>

void *func ();

void handler1 ()
{
        printf ("\nIn handler 1\n");
}

void handler2 ()
{
        printf ("\nIn handler 2\n");
}

void handler3 ()
{ printf ("\nIn handler 3\n"); }
int main ()
{
        int err=-1;
        pthread_t t1,t2;


        signal (SIGUSR1, handler1);
        sleep(5);
        signal (SIGUSR1, handler2);
        sleep(5);
        signal (SIGUSR1, handler3);
        sleep(5);
        pthread_create (&t1, NULL, &func, NULL);

        sleep(20);

        return 0;
}

void *func()
{
        while (1) usleep(10);
}



More information about the Kernelnewbies mailing list