/kern_oII/Documentation/watchdog/src/watchdog-simple.c

http://omnia2droid.googlecode.com/ · C · 27 lines · 26 code · 1 blank · 0 comment · 6 complexity · 577b3b84016ea97ed4b5a6f417623a4b MD5 · raw file

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <fcntl.h>
  5. int main(void)
  6. {
  7. int fd = open("/dev/watchdog", O_WRONLY);
  8. int ret = 0;
  9. if (fd == -1) {
  10. perror("watchdog");
  11. exit(EXIT_FAILURE);
  12. }
  13. while (1) {
  14. ret = write(fd, "\0", 1);
  15. if (ret != 1) {
  16. ret = -1;
  17. break;
  18. }
  19. ret = fsync(fd);
  20. if (ret)
  21. break;
  22. sleep(10);
  23. }
  24. close(fd);
  25. return ret;
  26. }