linux watchdog demo hacking
/**********************************************************************
* linux watchdog demo hacking
* 说明:
* 本文主要解析linux watchdog大概应该如何操作。
*
* 2016-3-28 深圳 南山平山村 曾剑锋
*********************************************************************/ #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.
* 这个函数仅仅是发送一个IOCTL命令给驱动,重新启动Watchdog的内部时钟计数器,
* 这样就不会导致系统重启。
*/
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.
* 主程序,通过传递参数-d来关闭watchdog,-e来打开watchdog。
*/
int main(int argc, char *argv[])
{
int flags; // 打开设备节点
fd = open("/dev/watchdog", O_WRONLY);
if (fd == -) {
fprintf(stderr, "Watchdog device not enabled.\n");
fflush(stderr);
exit(-);
} if (argc > ) {
// 关闭watchdog
if (!strncasecmp(argv[], "-d", )) {
flags = WDIOS_DISABLECARD;
ioctl(fd, WDIOC_SETOPTIONS, &flags);
fprintf(stderr, "Watchdog card disabled.\n");
fflush(stderr);
exit();
// 使能watchdog
} else if (!strncasecmp(argv[], "-e", )) {
flags = WDIOS_ENABLECARD;
ioctl(fd, WDIOC_SETOPTIONS, &flags);
fprintf(stderr, "Watchdog card enabled.\n");
fflush(stderr);
exit();
} else {
fprintf(stderr, "-d to disable, -e to enable.\n");
fprintf(stderr, "run by itself to tick the card.\n");
fflush(stderr);
exit();
}
} else {
fprintf(stderr, "Watchdog Ticking Away!\n");
fflush(stderr);
} while() {
// 每一秒喂狗一次
keep_alive();
sleep();
}
}
linux watchdog demo hacking的更多相关文章
- Linux watchdog
使用 watchdog 构建高可用性的 Linux 系统及应用https://www.ibm.com/developerworks/cn/linux/l-cn-watchdog/index.html ...
- linux SPI bus demo hacking
/********************************************************************** * linux SPI bus demo hacking ...
- Linux SocketCan client server demo hacking
/*********************************************************************** * Linux SocketCan client se ...
- Qt 控制watchdog app hacking
/************************************************************************** * Qt 控制watchdog app hack ...
- am335x Qt SocketCAN Demo hacking
/*********************************************************************************** * am335x Qt Soc ...
- Cmockery macro demo hacking
/********************************************************************* * Cmockery macro demo hacking ...
- Linux Watchdog Test Program
/*********************************************************************** * Linux Watchdog Test Progr ...
- Qt QML referenceexamples attached Demo hacking
/********************************************************************************************* * Qt ...
- Linux watchdog 关闭退出功能
Linux 程序退出的时候,程序是会把 watchdog 调用 release 功能.
随机推荐
- Battle Over Cities (25)(DFS、连通图)
It is vitally important to have all the cities connected by highways in a war. If a city is occupied ...
- OFBIZ bug_create-component ERROR
开发环境:win7 64位 Eclipse 运行create-component,报一下错误: Buildfile: F:\workspace\opensource\apache-obiz\apach ...
- Maven使用本地jar包(小私服?支持自动打入war包)
1.库目录结构 D:\maven-local-repo\cn\xcf007\MD5\1.0\MD5-1.0.jar 2.安装到该本地库 mvn install:install-file -Dfile= ...
- 【BZOJ2330】 [SCOI2011]糖果
Description 幼儿园里有N个小朋友,lxhgww老师现在想要给这些小朋友们分配糖果,要求每个小朋友都要分到糖果.但是小朋友们也有嫉妒心,总是会提出一些要求,比如小明不希望小红分到的糖果比他的 ...
- 演示demo开发问题及解决方案集锦
模型处理问题: 1. 3Dmax模型导入Unity单位设置: 自定义->单位设置->系统单位设置与显示单位比例都调成厘米 2. 3Dmax中材质贴图: 点击材质编辑器[在模式下可以选择精简 ...
- 异常:HRESULT: 0x80070057 (E_INVALIDARG) 的处理
碰到这个异常的原因很偶然: 现象:Solution在ReBuild过程中断电了,来电恢复了,重析编译整个Solution不报错,但在浏览页面时始终无法正常浏览,而在design的视图中,每个aspx的 ...
- JAVA多线程synchronized详解
Java语言的关键字,当它用来修饰一个方法或者一个代码块的时候,能够保证在同一时刻最多只有一个线程执行该段代码. 当两个并发线程访问同一个对象object中的这个synchronized(this)同 ...
- 过长文字自动换行的技巧 Word-Break Word-Wrap
在很多时候,为了防止内容过长把表格或容器撑破, 我们都需要为容器加上自动换行的功能. 实现自动换行,用CSS来实现,通常有两种方式: word-break: 取值为 normal, break-all ...
- sql之left join、right join、inner join的区别(转)
感谢:http://www.cnblogs.com/pcjim/articles/799302.html ----------------------------------------------- ...
- oracle-number(5,2)
insert into emp values(70000.123); 只能存储 整数的前3位, 小数点后面的2位