StudyingUnixInterface/10/signal/pause2.c
2021-01-11 18:00:36 +08:00

21 lines
318 B
C

#include <signal.h>
#include <unistd.h>
#include <setjmp.h>
#include <stdio.h>
static jmp_buf env_alrm;
static void sig_alrm(int signo) {
longjmp(env_alrm, 1);
}
int main(void) {
if(signal(SIGALRM, sig_alrm) == SIG_ERR)
return -1;
if(setjmp(env_alrm) == 0) {
alarm(3);
pause();
}
return 0;
}