clinuxmessagealarmsigaction

"Alarm clock" message in linux


struct sigaction act;
memset(&act,0,sizeof act);
sigaction(SIGALRM, &act, NULL);
alarm(any_seconds);

My alarm code in linux.

I met "Alarm clock" message. But I don't want met this message.

How can I do? please help.


Solution

  • You can catch the signal

    static void alarmHandler(int signo)
    {
        (void)signo;
        printf("Another message\n"); // or skip this line
    }
    
    ...
    alarm(any_seconds);
    signal(SIGALRM, alarmHandler);