[BACK]Return to watchdog-simple.c CVS log [TXT][DIR] Up to [Development] / linux-2.6-xfs / Documentation / watchdog / src

File: [Development] / linux-2.6-xfs / Documentation / watchdog / src / watchdog-simple.c (download)

Revision 1.3, Mon Dec 3 16:26:37 2007 UTC (9 years, 10 months ago) by lachlan.longdrop.melbourne.sgi.com
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +14 -4 lines

Merge up to 2.6.24-rc3
Merge of 2.6.x-xfs-melb:linux:30183b by kenmcd.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>

int main(void)
{
	int fd = open("/dev/watchdog", O_WRONLY);
	int ret = 0;
	if (fd == -1) {
		perror("watchdog");
		exit(EXIT_FAILURE);
	}
	while (1) {
		ret = write(fd, "\0", 1);
		if (ret != 1) {
			ret = -1;
			break;
		}
		ret = fsync(fd);
		if (ret)
			break;
		sleep(10);
	}
	close(fd);
	return ret;
}