--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <signal.h>
+#include <time.h>
+
+struct timespec *start_time, *stop_time;
+int done;
+
+void handle_start() {
+
+ if(clock_gettime(CLOCK_MONOTONIC, start_time) == -1) {
+
+ printf("failed to get start time.\n");
+ exit(1);
+ }
+
+ pause();
+}
+
+void handle_stop() {
+
+ long int start_sec, stop_sec, delta;
+
+ if(clock_gettime(CLOCK_MONOTONIC, stop_time) == -1) {
+
+ printf("failed to get stop time.\n");
+ exit(1);
+ }
+
+ start_sec = ((long int) start_time->tv_sec);
+ stop_sec = ((long int) stop_time->tv_sec);
+
+ delta = stop_sec - start_sec;
+
+ printf("%ld seconds elapsed between signals.\n", delta);
+
+ done = 1;
+}
+
+int main(int argc, char *argv[]) {
+
+ done = 0;
+
+ start_time = (struct timespec *) calloc(1, sizeof(struct timespec));
+ stop_time = (struct timespec *) calloc(1, sizeof(struct timespec));
+
+ if(signal(SIGTSTP, handle_start) == SIG_ERR ||
+ signal(SIGCONT, handle_stop) == SIG_ERR) {
+
+ printf("could not bind signal handlers\n");
+ return 1;
+ }
+
+ terminate_check:
+
+ pause();
+
+ if(!done)
+ goto terminate_check;
+
+ free(start_time);
+ free(stop_time);
+
+ return 0;
+}