Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Jean Delvare | 2db02c0 | 2006-09-28 09:35:27 +0200 | [diff] [blame] | 2 | #include <stdio.h> |
Randy Dunlap | 56fb9e5 | 2006-05-21 20:58:10 -0700 | [diff] [blame] | 3 | #include <stdlib.h> |
Jean Delvare | 2db02c0 | 2006-09-28 09:35:27 +0200 | [diff] [blame] | 4 | #include <unistd.h> |
Randy Dunlap | 56fb9e5 | 2006-05-21 20:58:10 -0700 | [diff] [blame] | 5 | #include <fcntl.h> |
6 | |||||
WANG Cong | 06063e2 | 2007-10-06 11:17:13 +0800 | [diff] [blame] | 7 | int main(void) |
8 | { | ||||
Randy Dunlap | 56fb9e5 | 2006-05-21 20:58:10 -0700 | [diff] [blame] | 9 | int fd = open("/dev/watchdog", O_WRONLY); |
WANG Cong | 06063e2 | 2007-10-06 11:17:13 +0800 | [diff] [blame] | 10 | int ret = 0; |
Randy Dunlap | 56fb9e5 | 2006-05-21 20:58:10 -0700 | [diff] [blame] | 11 | if (fd == -1) { |
12 | perror("watchdog"); | ||||
WANG Cong | 06063e2 | 2007-10-06 11:17:13 +0800 | [diff] [blame] | 13 | exit(EXIT_FAILURE); |
Randy Dunlap | 56fb9e5 | 2006-05-21 20:58:10 -0700 | [diff] [blame] | 14 | } |
15 | while (1) { | ||||
WANG Cong | 06063e2 | 2007-10-06 11:17:13 +0800 | [diff] [blame] | 16 | ret = write(fd, "\0", 1); |
17 | if (ret != 1) { | ||||
18 | ret = -1; | ||||
19 | break; | ||||
20 | } | ||||
Randy Dunlap | 56fb9e5 | 2006-05-21 20:58:10 -0700 | [diff] [blame] | 21 | sleep(10); |
22 | } | ||||
WANG Cong | 06063e2 | 2007-10-06 11:17:13 +0800 | [diff] [blame] | 23 | close(fd); |
24 | return ret; | ||||
Randy Dunlap | 56fb9e5 | 2006-05-21 20:58:10 -0700 | [diff] [blame] | 25 | } |