Main Page   Compound List   File List   Compound Members   File Members   Related Pages  

watchdog.c File Reference

#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/time.h>
#include <stdio.h>
#include <syslog.h>
#include "ahm.h"
#include "utils.h"
#include "watchdog.h"

Functions

int reset_watchdog (void)
int setup_watchdog_callback (void)

Variables

int watchdog_fd = -1
gboolean watchdog_enabled = FALSE
unsigned long watchdog_period = WATCHDOG_RESET_INTERVAL

Function Documentation

int reset_watchdog void   
 

This function writes a value to the /dev/watchdog interface. If the device is not opened, it returns without doing anything.

If this function is unable to reset the watchdog timer the following message will be logged:

Failed to reset watchdog timer

int setup_watchdog_callback void   
 

This function sets up the timer for the watchdog update It will open the watchdog device interface, for example, /dev/watchdog and the timer callback function will handle writing to the file (thus reseting the timer). If the timer is so short that this function cannot open the /dev/watchdog interface and install the timer callback, then the timer will expire though not necessarily because of a system error.

If the watchdog device cannot be opening, this function returns without setting up the timer. If setting up the timer callback fails, then the watchdog device is closed. It is possible that the timer may expire, depending upon the interval, before the device is closed in this case.

It should be noted that the system timer has a resolution of about 10ms, so any update period smaller than this may not work correctly. Currently, only a value of seconds is accepted in a range of 1 second to the max value of a long.

Returns:
E_INVALID if unable to setup watchdog timer reset callback or if the watchdog period is too small. SUCCESS if device was opened and callback installed

Todo:
Allow watchdog upate values in milliseconds.


Variable Documentation

gboolean watchdog_enabled = FALSE
 

Indicates if the watchdog reset feature should be enabled

int watchdog_fd = -1
 

This is the file descriptor of the watchdog interface

unsigned long watchdog_period = WATCHDOG_RESET_INTERVAL
 

Sets the interval of time between reseting the watchdog timer


Generated on Wed Oct 30 15:21:17 2002 for Application Heartbeat Monitor by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002