blob: 9ce66d2ca2a9c02e56bb338ff1cdf7a4ca24e702 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Jean Delvare2db02c02006-09-28 09:35:27 +02002#include <stdio.h>
Randy Dunlap56fb9e52006-05-21 20:58:10 -07003#include <stdlib.h>
Jean Delvare2db02c02006-09-28 09:35:27 +02004#include <unistd.h>
Randy Dunlap56fb9e52006-05-21 20:58:10 -07005#include <fcntl.h>
6
WANG Cong06063e22007-10-06 11:17:13 +08007int main(void)
8{
Randy Dunlap56fb9e52006-05-21 20:58:10 -07009 int fd = open("/dev/watchdog", O_WRONLY);
WANG Cong06063e22007-10-06 11:17:13 +080010 int ret = 0;
Randy Dunlap56fb9e52006-05-21 20:58:10 -070011 if (fd == -1) {
12 perror("watchdog");
WANG Cong06063e22007-10-06 11:17:13 +080013 exit(EXIT_FAILURE);
Randy Dunlap56fb9e52006-05-21 20:58:10 -070014 }
15 while (1) {
WANG Cong06063e22007-10-06 11:17:13 +080016 ret = write(fd, "\0", 1);
17 if (ret != 1) {
18 ret = -1;
19 break;
20 }
Randy Dunlap56fb9e52006-05-21 20:58:10 -070021 sleep(10);
22 }
WANG Cong06063e22007-10-06 11:17:13 +080023 close(fd);
24 return ret;
Randy Dunlap56fb9e52006-05-21 20:58:10 -070025}