Skip to content

Instantly share code, notes, and snippets.

@andrestc
Last active July 6, 2017 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrestc/58f5b92cbc828ba09eb796dba303837d to your computer and use it in GitHub Desktop.
Save andrestc/58f5b92cbc828ba09eb796dba303837d to your computer and use it in GitHub Desktop.
#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