Last active
July 6, 2017 02:18
-
-
Save andrestc/58f5b92cbc828ba09eb796dba303837d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <signal.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
void handler(int sig) | |
{ | |
exit(sig); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
int duration; | |
if (argc > 1) | |
{ | |
duration = atoi(argv[1]); | |
printf("Sleeping for %ds\n", duration); | |
sleep(duration); | |
exit(EXIT_SUCCESS); | |
} | |
if(signal(SIGQUIT, handler) == SIG_ERR) | |
exit(EXIT_FAILURE); | |
for (;;) | |
pause(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment