This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

强制中止或者退出看门狗watchdog测试程序,为什么系统没有复位?



看门狗测试程序如下:
int fd;

void catch_int(int signum)
{
        signal(SIGINT, catch_int);

        printf("In signal handler\n");
        if(0 != close(fd))
                printf("Close failed in signal handler\n");
        else
                printf("Close succeeded in signal handler\n");
}



int main(int argc, const char *argv[]) {
        
        int sleep_time = atoi(argv[1]);

        int data = 0;
        int ret_val;

        //signal(SIGINT, catch_int);

        fd=open("/dev/watchdog",O_WRONLY);       
        if (fd==-1) {
                perror("watchdog");
                return 1;
        }

        ret_val = ioctl (fd, WDIOC_GETTIMEOUT, &data);
        if (ret_val) {
                printf ("\nWatchdog Timer : WDIOC_GETTIMEOUT failed");
        }
        else {
                printf ("\nCurrent timeout value is : %d seconds\n", data);
        }

        data = 10;

        ret_val = ioctl (fd, WDIOC_SETTIMEOUT, &data);
        if (ret_val) {
                printf ("\nWatchdog Timer : WDIOC_SETTIMEOUT failed");
        }
        else {
                printf ("\nNew timeout value is : %d seconds", data);
        }

        ret_val = ioctl (fd, WDIOC_GETTIMEOUT, &data);
        if (ret_val) {
                printf ("\nWatchdog Timer : WDIOC_GETTIMEOUT failed");
        }
        else {
                printf ("\nCurrent timeout value is : %d seconds\n", data);
        }

        while(1) 
        {
            if (1 != write(fd, "\0", 1))
                    {
                            printf("Write failed\n");
                            break;
                    }
                    else
                        printf("Write succeeded\n");

            sleep(sleep_time);
        }

    
    if (0 != close (fd))
                printf("Close failed\n");
        else
                printf("Close succeeded\n");


        return 0;
}

测试如下:
由于硬件没有使用RSTOUT引脚,用的是软件看门狗,
./sawatchdog 3,只要时间小于10s,系统不会复位,
如果./sawatchdog 15,时间大于10,系统复位。
这些测试正常,但是如果测试程序运行过程中,按ctrl+c按键中止程序运行,或者killall sawatchdog,系统就一直不会复位,
为什么?谢谢!