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