Skip to content

Instantly share code, notes, and snippets.

@makerj
Created February 23, 2017 02:40
Show Gist options
  • Save makerj/a16dcb3e38d252df56c5cb43a14c9f3b to your computer and use it in GitHub Desktop.
Save makerj/a16dcb3e38d252df56c5cb43a14c9f3b to your computer and use it in GitHub Desktop.

Revisions

  1. makerj created this gist Feb 23, 2017.
    14 changes: 14 additions & 0 deletions alarm-sigaction-example.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    // once
    struct sigaction sigact, old_sigact;
    sigact.sa_handler = handler;
    sigemptyset(&sigact.sa_mask);
    sigact.sa_flags = SA_INTERRUPT;
    sigaction(SIGALRM, &sigact, &old_sigact) < 0);


    // somewhere loop
    while(1) {
    alarm(5);
    blocking_task();
    alarm(0);
    }