00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include <stdio.h>
00023 #include <signal.h>
00024
00025 #include "monitor.h"
00026
00039
00040
00041
00047 Sigfunc *signal(int signo, Sigfunc *func) {
00048
00049 struct sigaction act, oact;
00050
00051 act.sa_handler = func;
00052 sigemptyset(&act.sa_mask);
00053 act.sa_flags = 0;
00054 if (signo == SIGALRM) {
00055 #ifdef SA_INTERRUPT
00056 act.sa_flags |= SA_INTERRUPT;
00057 #endif
00058 } else {
00059 #ifdef SA_RESTART
00060 act.sa_flags |= SA_RESTART;
00061 #endif
00062 }
00063 if (sigaction(signo, &act, &oact) < 0)
00064 return(SIG_ERR);
00065
00066 return(oact.sa_handler);
00067
00068 }
00069
00070
00075 void set_alarm_handler(void *func) {
00076
00077 struct sigaction sa;
00078
00079 sa.sa_handler= func;
00080 sa.sa_flags= 0;
00081 sigemptyset(&sa.sa_mask);
00082 sigaction(SIGALRM, &sa, NULL);
00083
00084 }