Created
September 17, 2013 06:01
-
-
Save danish-rehman/6590557 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 <stdio.h> | |
#include <time.h> | |
#include <signal.h> | |
int handler(); | |
void show_status(); | |
int long_running_procedure( struct timespec time_sleep, struct timespec time_rem); | |
int status = 0; | |
int main(int argc, char *argv[]) | |
{ | |
struct timespec time_sleep, time_rem; | |
time_sleep.tv_sec = 3; | |
time_sleep.tv_nsec = 100; | |
//sigset(SIGINT, handler); | |
sigset(SIGINT, show_status); | |
long_running_procedure(time_sleep, time_rem); | |
} | |
int handler() | |
{ | |
printf("Handler is called\n"); | |
} | |
void show_status() | |
{ | |
printf("Status = %d\n", status); | |
} | |
int long_running_procedure( struct timespec time_sleep, struct timespec time_rem) | |
{ | |
while(1){ | |
nanosleep(&time_sleep, &time_rem); | |
status=+1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment