Chinaunix

标题: kill 喂狗进程后系统为何不重启? [打印本页]

作者: Nice026    时间: 2012-06-14 14:24
标题: kill 喂狗进程后系统为何不重启?
S3C2440的板子,打开看门狗后,系统会按着设置时间自动重启,加入喂狗程序后,系统不再启动,应该是喂狗程序起作用了,现在执行 kill -9 345  ,(345是喂狗进程PID),过了设置时间后系统仍不重启,不知怎么回事,执行ps,已看不到喂狗进程
作者: daniel_kohler    时间: 2012-06-15 12:33
回复 1# Nice026


    有一种可能,你的喂狗程序把/dev/watchdog打开了,你直接将喂狗程序的进程kill掉,/dev/watchdog还没有关闭?
作者: Nice026    时间: 2012-06-15 16:51
回复 2# daniel_kohler
/dev/watchdog 是在喂狗进程里打开的,喂狗进程运行后,系统不重启了,这是对的,但是把喂狗进程kill -9 之后,系统应该重启才对啊?因为不喂狗了呀!
我在喂狗程序里加了打印信息,喂一次狗,打印一次信息,喂狗程序运行时能正常打印信息,把喂狗进程kill掉之后,不再打印信息了,ps后也看不到喂狗进程了,但系统也不再重启了,到底哪的原因?


   
作者: daniel_kohler    时间: 2012-06-16 01:05
回复 3# Nice026


    把你的代码贴出来看看。
作者: Nice026    时间: 2012-06-18 10:40
本帖最后由 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

作者: Nice026    时间: 2012-06-18 10:44
本帖最后由 Nice026 于 2012-06-18 10:47 编辑

刚才显示很多表情符号,这下好了
作者: daniel_kohler    时间: 2012-06-18 13:20
回复 6# Nice026


    你在kill了你的watchdog之后,cat /dev/watchdog,看一下里面的值是什么?
    http://bbs.chinaunix.net/thread-3743855-1-2.html
作者: Nice026    时间: 2012-06-18 16:49
回复 7# daniel_kohler

kill掉喂狗进程后,执行“cat /dev/watchdog”,显示“cat: Read Error :Invalid argument”
   




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2