📄 preread.c
字号:
#include<stdio.h>
#include<pthread.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
void feeldog(int fd)
{
while(1)
{
sleep(1);
write(fd,NULL,NULL);
}
}
void main()
{
pthread_t id; /*线程的ID*/
int fd;
int rt; /*线程的描述符*/
int i ;
/*打开看门狗设备*/
fd=open("/dev/watchdog",O_RDWR);
if(fd<0)
printf("open dev err:\n");
//创建线程
rt=pthread_create(&id,NULL,(void *)feeldog,fd);
if(rt!=0)
{
printf("create pthread err !\n");
}
while(1)
{
/*这是个死循环,
目的是为了不让进程结束
线程可以一直喂狗
*/
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -