Using signals in redhat linux

Claudio Lavecchia Claudio.Lavecchia@eurecom.fr
Thu Aug 5 17:36:00 GMT 2004


Hello people,

I have a quick question about using signals in Linux environment - 
redhat 7.3.
I'm using GCC version 2.96.
I'm trying to launch and intercept signals - but the signals never get 
intercepted.

Any of you guys have an idea of why? Do I have to set any compile option?

I include the very simple test (using both alarm() and raise() to send 
signals)

Thanks a lot

Claudio

#include <stdio.h>
#include <signal.h>
#include <time.h>


void processAlarm()
{
    signal(SIGALRM, processAlarm);
    printf("ALARM INTERCEPTED");
    alarm(3);
}

void processSIG()
{
    signal(100, processSIG);
    printf("SIG INTERCEPTED");  
}

int main(int argc, char *argv[])
{
    printf("Launching Alarm Test\n");
    signal(SIGALRM, processAlarm);

    printf("Launching Alarm (previous alarm value: %d)\n",alarm(3));   
    printf("Alarm value:%d\n",alarm(0));

    signal(100, processSIG);
    raise(100);
       
    while (1);
    return 0;
}



More information about the Gcc-help mailing list