Skip to content

Commit

Permalink
[WATCHDOG] Documentation/watchdog/src/watchdog-simple.c: improve this…
Browse files Browse the repository at this point in the history
… code

Make some improvements for Documentation/watchdog/src/watchdog-simple.c.

Signed-off-by: WANG Cong <[email protected]>
Signed-off-by: Wim Van Sebroeck <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
congwang authored and Wim Van Sebroeck committed Oct 23, 2007
1 parent c283cf2 commit 06063e2
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Documentation/watchdog/src/watchdog-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@
#include <unistd.h>
#include <fcntl.h>

int main(int argc, const char *argv[]) {
int main(void)
{
int fd = open("/dev/watchdog", O_WRONLY);
int ret = 0;
if (fd == -1) {
perror("watchdog");
exit(1);
exit(EXIT_FAILURE);
}
while (1) {
write(fd, "\0", 1);
fsync(fd);
ret = write(fd, "\0", 1);
if (ret != 1) {
ret = -1;
break;
}
ret = fsync(fd);
if (ret)
break;
sleep(10);
}
close(fd);
return ret;
}

0 comments on commit 06063e2

Please sign in to comment.