aboutsummaryrefslogtreecommitdiffstats
path: root/alarm.c
blob: a0bfa356edbdb4ad0da7822ec88ba3c1082ced0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <signal.h>
#include <stdio.h>
#include <sys/select.h>
#include <unistd.h>
#include <time.h>

volatile unsigned int variable = 0;
volatile unsigned int print_variable = 0;

void alarm_handler(int signum)
{
    alarm(60);
}

int main()
{        
    signal(SIGALRM, alarm_handler);
    alarm(1);

    for (;;)
    {
        select(0, NULL, NULL, NULL, NULL);
 time_t t = time(NULL);
 struct tm tm = *localtime(&t);
 printf("%d-%d-%d %d:%d:%d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);

    }
}