https://github.com/torvalds/linux
Raw File
Tip revision: 7c53f6b671f4aba70ff15e1b05148b10d58c2837 authored by Linus Torvalds on 10 January 2021, 22:34:50 UTC
Linux 5.11-rc3
Tip revision: 7c53f6b
watchdog-simple.c
// SPDX-License-Identifier: GPL-2.0
#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;
		}
		sleep(10);
	}
	close(fd);
	return ret;
}
back to top