[英]watchdog: Device or resource busy
I'm trying to feed the watchdog device - /dev/watchdog
in Raspbian - from C. 我正在尝试从Ras中提供看门狗设备 -
/dev/watchdog
。
The problem is no matter how i try to access the device always throws busy or permission denied errors (as the process is already running and being fed by the system..). 问题是无论我如何尝试访问设备总是抛出繁忙或权限被拒绝的错误(因为该进程已经在运行并由系统提供...)。
In the watchdog API says that '..the driver will not disable the watchdog unless a specific magic character 'V' has been sent to /dev/watchdog just before closing the file.' 在看门狗API中说'..驱动程序不会禁用看门狗,除非在关闭文件之前已经将特定的魔术字符“V”发送到/ dev / watchdog。 but then again i cannot write
/dev/watchdog
.. I tried: 但后来又说我不能写
/dev/watchdog
..我试过:
echo V > /dev/watchdog //bash, /dev/watchdog: Permission denied
open("/dev/watchdog", O_WRONLY); //C, Device or resource busy
Is there any way to free the device so i can control the heartbeat from C? 有没有办法释放设备,以便我可以控制C的心跳?
I had this problem when i worked with Raspberry Pi. 当我使用Raspberry Pi时,我遇到了这个问题。 My application used extensive CPU time.
我的应用程序使用了大量CPU时间 After 1 or 2 days work it caused the Raspberry pi hangs.
工作1或2天后,它会导致Raspberry pi挂起。 So i decided to use the wtchdog.
所以我决定使用wtchdog。 When i wanted to write watchdog device from C++ program i got same error.
当我想从C ++程序编写看门狗设备时,我得到了同样的错误。
The solution that i found: 我发现的解决方案:
open a new rule file sudo nano /etc/udev/rules.d/60-watchdog.rules
打开一个新的规则文件
sudo nano /etc/udev/rules.d/60-watchdog.rules
and add this line to the file KERNEL=="watchdog", MODE="0666"
并将此行添加到文件
KERNEL=="watchdog", MODE="0666"
After this, i was able to access watchdog form terminal screen or c++ program. 在此之后,我能够访问看门狗表格终端屏幕或c ++程序。
The issue I found was that systemd and wd_keepalive seemed to be using the watchdog resource per fuser output: 我发现的问题是systemd和wd_keepalive似乎每个热凝器输出使用看门狗资源:
>sudo fuser -v /dev/watchdog
USER PID ACCESS COMMAND
/dev/watchdog: root 15087 F.... wd_keepalive
and 和
>sudo fuser -v /dev/watchdog
USER PID ACCESS COMMAND
/dev/watchdog: root 1 F.... systemd
I removed watchdog timer references from /etc/systemd/system.conf
to get rid of the busy issue on the systemd
busy system. 我从
/etc/systemd/system.conf
删除了看门狗定时器引用,以摆脱systemd
busy系统上的繁忙问题。
If you're feeling bold, you can kill -9 your wd_keepalive PID, then echo your character toward the /dev/watchdog
device, if you want to manually control the watchdog. 如果你感觉大胆,你可以杀死-9你的wd_keepalive PID,然后如果你想手动控制看门狗那么将你的角色回到
/dev/watchdog
设备。 I prefer just letting the daemon do its thing. 我更喜欢让守护进程做它的事情。
Unlike some other suggestions on SO and the net, I did not need to install watchdog as a device on the Pi eg in /boot/config.txt
. 与SO和网络上的其他一些建议不同,我不需要在Pi上安装看门狗作为设备,例如在
/boot/config.txt
。 Nor did I need to call any services other than via systemctl. 除了通过systemctl,我也不需要调用任何服务。 I just ran
我跑了
sudo apt-get install watchdog
sudo update-rc.d watchdog defaults
Then to configure watchdog I put these lines in /etc/watchdog.conf
然后配置看门狗我把这些行放在
/etc/watchdog.conf
watchdog-device = /dev/watchdog
# Set default Timeout
watchdog-timeout = 14
Then the only thing I needed to do to use watchdog was call this from my application, which I run after bootup: 然后我唯一需要做的就是使用看门狗从我的应用程序调用它,我在启动后运行:
sudo systemctl enable watchdog
sudo systemctl start watchdog
sudo systemctl -l status watchdog
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.