About signal handler install info

rahul dev rahul_dev_agg at yahoo.co.in
Thu Dec 1 05:13:24 EST 2011


See sigaction.

--- On Thu, 1/12/11, naveen yadav <yad.naveen at gmail.com> wrote:

> From: naveen yadav <yad.naveen at gmail.com>
> Subject: About signal handler install info
> To: Kernelnewbies at kernelnewbies.org, kernelnewbies at nl.linux.org
> Date: Thursday, 1 December, 2011, 3:33 PM
> 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);
> }
> 
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> 



More information about the Kernelnewbies mailing list