| 
 
贡献160 
飞刀51 FD
注册时间2016-2-24
在线时间5 小时积分27 
 
 
 | 
 
 
 楼主|
发表于 2016-11-30 17:36:00
|
显示全部楼层 
| /* * Watchdog Driver Test Program
 */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <linux/types.h>
 #include <linux/watchdog.h>
 
 int fd;
 
 /*
 * This function simply sends an IOCTL to the driver, which in turn ticks
 * the PC Watchdog card to reset its internal timer so it doesn't trigger
 * a computer reset.
 */
 static void keep_alive(void)
 {
 int dummy;
 
 ioctl(fd, WDIOC_KEEPALIVE, &dummy);
 }
 
 /*
 * The main program.  Run the program with "-d" to disable the card,
 * or "-e" to enable the card.
 */
 int main(int argc, char *argv[])
 {
 int flags;
 int i;
 fd = open("/dev/watchdog", O_WRONLY);
 
 if (fd == -1) {
 fprintf(stderr, "Watchdog device not enabled.\n");
 fflush(stderr);
 exit(-1);
 }
 
 
 
 for(i=0;i<100;i++) {
 
 keep_alive();
 sleep(1);
 
 }
 }
 这是我的代码,程序退出看门狗不起作用
 | 
 |