mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 01:10:04 +00:00
![Shuah Khan](/assets/img/avatar_default.png)
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>
24 lines
346 B
C
24 lines
346 B
C
#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;
|
|
}
|