Skip to contentSkip to conversation

Regrading signal/sigaction.

DISCUSSION siva kumar 1 participant 1 message Jun 26, 2001

lore
Share & tools
lore

siva kumar

author
#0 lore raw

Hi,

Is it possible to pass any local variable as an argument in the signal handler function.Basically I want to print the value of the local variable in the signal handler function.

In the below program I want to print the value of a in the timeout function(siganl handler), whenever the Alaram signal send.

Your comment are welcomed.

My prototype code is:

#include<stdio.h>
#include<signal.h>
void timeout(int signo,int a)

{
        printf ("timeout");
        printf("the value is %d and %d",signo,a);
}

main()

{
        int a =5;
        struct sigaction act,oact;
        act.sa_handler = timeout;
        sigemptyset(&act.sa_mask);
        act.sa_flags = 0;
        sigaction(SIGALRM, &act, &oact);
 
        alarm(10);
        sleep(10);

}

Thanks,
siva.s

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/