samples: move watchdog example code from Documentation
Move watchdog examples to samples and remove it from Documentation Makefile. Create a new Makefile to build watchdog. It can be built from top level directory or from watchdog directory: Run make -C samples/watchdog or cd samples/watchdog; make Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
This commit is contained in:
24
samples/watchdog/watchdog-simple.c
Normal file
24
samples/watchdog/watchdog-simple.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd = open("/dev/watchdog", O_WRONLY);
|
||||
int ret = 0;
|
||||
if (fd == -1) {
|
||||
perror("watchdog");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
while (1) {
|
||||
ret = write(fd, "\0", 1);
|
||||
if (ret != 1) {
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
sleep(10);
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
Reference in New Issue
Block a user