1
0

shell_wdog.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * shell_startup.c
  3. */
  4. #include "private.h"
  5. #include <assert.h>
  6. #include "tinyrl/tinyrl.h"
  7. #include "lub/string.h"
  8. /*----------------------------------------------------------------------- */
  9. int clish_shell_timeout_fn(tinyrl_t *this)
  10. {
  11. tinyrl_crlf(this);
  12. fprintf(stderr, "Warning: Activity timeout. The session will be closed.\n");
  13. /* Return -1 to close session on timeout */
  14. return -1;
  15. }
  16. /*----------------------------------------------------------- */
  17. int clish_shell_wdog(clish_shell_t *this)
  18. {
  19. clish_context_t context;
  20. assert(this->wdog);
  21. context.shell = this;
  22. context.cmd = this->wdog;
  23. context.pargv = NULL;
  24. /* Call watchdog script */
  25. return clish_shell_execute(&context, NULL);
  26. }
  27. /*----------------------------------------------------------- */
  28. void clish_shell__set_wdog_timeout(clish_shell_t *this, unsigned int timeout)
  29. {
  30. assert(this);
  31. this->wdog_timeout = timeout;
  32. }
  33. /*----------------------------------------------------------- */
  34. unsigned int clish_shell__get_wdog_timeout(const clish_shell_t *this)
  35. {
  36. assert(this);
  37. return this->wdog_timeout;
  38. }