github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/pkg/strace/test/sleep.c (about)

     1  #include <stdio.h>
     2  #include <signal.h>
     3  #include <time.h>
     4  
     5  void sigint(int signal) {
     6    printf("got milk\n");
     7  }
     8  
     9  int main() {
    10    signal(SIGINT, &sigint);
    11  
    12    struct timespec ts;
    13    ts.tv_sec = 30;
    14    // nanosleep returns EINTR when interrupted by a signal. Don't restart it.
    15    nanosleep(&ts, NULL);
    16    printf("got interrupted\n");
    17    return 0;
    18  }