6d35ff54fe3c105afc63760dec5cab038ba8bc22
8 struct timespec
*start_time
, *stop_time
;
13 if(clock_gettime(CLOCK_MONOTONIC
, start_time
) == -1) {
15 printf("failed to get start time.\n");
24 long int start_sec
, stop_sec
, delta
;
26 if(clock_gettime(CLOCK_MONOTONIC
, stop_time
) == -1) {
28 printf("failed to get stop time.\n");
32 start_sec
= ((long int) start_time
->tv_sec
);
33 stop_sec
= ((long int) stop_time
->tv_sec
);
35 delta
= stop_sec
- start_sec
;
37 printf("%ld seconds elapsed between signals.\n", delta
);
42 int main(int argc
, char *argv
[]) {
46 start_time
= (struct timespec
*) calloc(1, sizeof(struct timespec
));
47 stop_time
= (struct timespec
*) calloc(1, sizeof(struct timespec
));
49 if(signal(SIGTSTP
, handle_start
) == SIG_ERR
||
50 signal(SIGCONT
, handle_stop
) == SIG_ERR
) {
52 printf("could not bind signal handlers\n");