Skip to content

Commit

Permalink
Retry if open(WDT) fails after handover from Finit
Browse files Browse the repository at this point in the history
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
  • Loading branch information
troglobit committed Jul 9, 2018
1 parent 7d82c15 commit f2e91a5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/finit.c
Expand Up @@ -83,11 +83,27 @@ int wdt_register(void)
*/
int wdt_handover(const char *devnode)
{
int retries = 3;
int rc = -1;

DEBUG("Attempting WDT handover with Finit ...");
if (wdt_register())
return -1;

return open(devnode, O_WRONLY);
/*
* Don't give up immediately, give the current
* daemon time to exit and the kernel time to
* close the WDT device.
*/
while (rc < 0 && retries--) {
rc = open(devnode, O_WRONLY);
if (rc >= 0)
break;

sleep(1);
}

return rc;
}

/**
Expand Down

0 comments on commit f2e91a5

Please sign in to comment.