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

#define PERIOD_SEC 1
#define PERIOD_NSEC 10

void handler()
{
    printf("Top !\n");
}

int main()
{
    int indes =0;

    timer_t timer_id;
    struct itimerspec info_timer;

    signal(SIGALRM, handler);

    timer_create(CLOCK_REALTIME, NULL, &timer_id);

    info_timer.it_value.tv_sec = PERIOD_SEC;
    info_timer.it_value.tv_nsec = PERIOD_NSEC;

    info_timer.it_interval.tv_sec = PERIOD_SEC;
    info_timer.it_interval.tv_nsec = PERIOD_NSEC;

    timer_settime(timer_id, 0, &info_timer, NULL);

    while(1)
    {
        printf("%d\n", indes);
        indes++;
        pause();
    }
    return 0;
}
