ccplusplus.com
Learn C, C++ Concepts
Tuesday, October 18, 2011
alarm function example in c
/*********************************************************************** * File : alarm.c * Author : Saurabh Gupta * Desc : alarm function example * Source : http://saurabhgupta0527.blogspot.com/2011/08/posix-signal-tutorial.html * Created : PM 08:18 18 October 2011 * Note : ************************************************************************/ #include <stdio.h> #include <signal.h> /* * number of times the handle will run: */ volatile int breakflag = 3; void handle(int sig) { printf("http://saurabhgupta0527.blogspot.com\n"); --breakflag; alarm(1); } int main() { signal(SIGALRM, handle); alarm(1); while(breakflag) { sleep(1); } printf("done\n"); return 0; } /* * * [sgupta@rhel55x86 signal]$ gcc alarm.c -o alarm. [sgupta@rhel55x86 signal]$ ./alarm http://saurabhgupta0527.blogspot.com http://saurabhgupta0527.blogspot.com http://saurabhgupta0527.blogspot.com done [sgupta@rhel55x86 signal]$ */
See Also
POSIX Signal tutorial and example codes
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment