watchdog.h File Reference

Declare SIGALRM/Watchdog for Windows/Linux. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ctl_watchdog_handler ctl_watchdog_init (ctl_watchdog_handler handler)
void ctl_watchdog_kick (int milliseconds)


Detailed Description

Declare SIGALRM/Watchdog for Windows/Linux.

Author:
David Mace

Definition in file watchdog.h.


Function Documentation

ctl_watchdog_handler ctl_watchdog_init ( ctl_watchdog_handler  handler  ) 

Initialize the watchdog; you have one minute to kick it

Parameters:
handler Watchdog handler callback to call when 'kick' doesn't happen
Returns:
Old handler, if any

Definition at line 59 of file watchdog.c.

References assertcodeptr, and ctl_mstime().

00060 {
00061     ctl_watchdog_handler old = wd_handler;
00062     wd_handler = NULL == handler ? ctl_watchdog_handler_default : handler;
00063     assertcodeptr(wd_handler);
00064 #ifdef WIN32
00065     msexpire = ctl_mstime() + 60000;
00066     hSleepy = CreateEvent( NULL, FALSE, FALSE, NULL );
00067     hThread = (HANDLE)_beginthread( WatchdogThreadProc, 0, NULL );
00068 #else
00069     {   /* Assume POSIX */
00070         struct sigaction action;
00071         action.sa_handler = sigalrm_callback;
00072         sigemptyset(&action.sa_mask);
00073         action.sa_flags = 0;
00074         /* alarm() is our watchdog */
00075         sigaction(SIGALRM, &action, NULL);
00076     }
00077     alarm(60);
00078 #endif
00079     return old;
00080 }

Here is the call graph for this function:

void ctl_watchdog_kick ( int  milliseconds  ) 

Initialize the watchdog

Parameters:
milliseconds How long until watchdog callback is triggered We only have second precision, but it gets confusing consistently dealing with milliseconds in other places

Definition at line 87 of file watchdog.c.

References ctl_mstime().

00088 {
00089 #ifdef WIN32
00090     msexpire = ctl_mstime() + milliseconds;
00091     SetEvent( hSleepy );
00092 #else
00093     alarm((milliseconds+999)/1000);
00094 #endif
00095 }

Here is the call graph for this function:


Generated on Fri Jan 2 15:28:36 2009 for Squat by  doxygen 1.5.6