Add code to set up a timer (using setitimer) for s seconds (where s is obtained from the command line). You shouldn't use real time, since your results will be affected if your system is busy. Instead, use ITIMER_PROF to make the itimer send a SIGPROF
struct itimerval it_val;
    struct timeval interval_next;
    struct timeval interval_current;
    interval_next.tv_sec = 0;
    interval_next.tv_usec = 0;
    interval_current.tv_sec = seconds;
    interval_current.tv_usec = 0;
    it_val.it_interval = interval_next;
    it_val.it_value = interval_current;

    setitimer(ITIMER_PROF, &it_val, NULL);