Definition | #include <signal.h> unsigned int alarm(unsigned int sec);
|
Return val. Notes | Time remaining in the alarm clock before execution of the A number of Since the alarm clock has a 1-second pulse, there may be time shifts of up to a second If the signal is intercepted (see With the assignment: |
Example | The following program sends an asterisk to the standard output approx. every two seconds: #include <stdio.h> #include <signal.h> void f(int sig) /* Signal handling for SIGALRM */ { printf("*\n"); alarm(2); /* Resetting of alarm clock; all further asterisks */ } int main(void) { signal(SIGALRM + SIG_PS, f); alarm(2); /* First asterisk */ for(;;) ; return 0; } |
See also | signal, sleep |