- 论坛徽章:
- 0
|
本帖最后由 Nice026 于 2012-06-18 10:46 编辑
回复 4# daniel_kohler
这是喂狗程序。
1 #include<unistd.h>
2 #include<sys/types.h>
3 #include<sys/stat.h>
4 #include<fcntl.h>
5 #include<stdio.h>
6 #include<stdlib.h>
7 #include<errno.h>
8 #include<linux/watchdog.h>
9
10 int main(int argc,char **argv)
11 {
12 int fd =0;
13 int n =0;
14 int i =0;
15 fd = open("/dev/watchdog",O_RDONLY);
16 if(fd<0) {
17 perror("/dev/watchdog" ) ;
18 return -1;
19 }
20 for( ; ; ) {
21 ioctl(fd,WDIOC_KEEPALIVE);
22 printf("\n feed the watchdog !" ) ;
23
24 sleep(3);
25 }
26 close(fd);
27 printf("\nstop to feeding the watchdog!\n" ) ;
28 return 0;
29
30 }
31
|
|