Created
April 19, 2013 15:32
-
-
Save ustbgaofan/5421136 to your computer and use it in GitHub Desktop.
This file contains 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 <stdio.h> | |
#include <time.h> | |
static void sig_alrm(int); /* one handler for both signals */ | |
time_t start,stop; | |
int main(void) | |
{ | |
signal(SIGALRM,sig_alrm); | |
start = time(NULL); | |
for ( ; ; ){ | |
sleep(4); | |
printf("[%ld] add an alarm\n",time(NULL)-start); | |
alarm(3); | |
} | |
} | |
static void sig_alrm(int signo) /* argument is signal number */ | |
{ | |
printf("[%ld] enter alram\n",time(NULL) - start); | |
sleep(5); | |
printf("[%ld] completed \n",time(NULL) - start); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment