Message ID | 20240327181353.10951-3-leigh@solinno.co.uk (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | xenwatchdogd enhancements | expand |
On 27.03.2024 19:13, leigh@solinno.co.uk wrote: > From: Leigh Brown <leigh@solinno.co.uk> > > Rework xenwatchdogd signal handling to do the minimum in the signal > handler. This is a very minor enhancement. > --- > tools/misc/xenwatchdogd.c | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) Throughout the series Signed-off-by: are missing from both you and Leigh. The latter you may of course add only in case of this either having been provided earlier (and dropped for an unknown reason), or with respective agreement. > --- a/tools/misc/xenwatchdogd.c > +++ b/tools/misc/xenwatchdogd.c > @@ -9,9 +9,11 @@ > #include <unistd.h> > #include <signal.h> > #include <stdio.h> > +#include <stdbool.h> > > xc_interface *h; > -int id = 0; > +bool safeexit = false; > +bool done = false; Seeing the subsequent patch adding static, please don't introduce new non-static items. Jan
On 28.03.2024 10:31, Jan Beulich wrote: > On 27.03.2024 19:13, leigh@solinno.co.uk wrote: >> From: Leigh Brown <leigh@solinno.co.uk> >> >> Rework xenwatchdogd signal handling to do the minimum in the signal >> handler. This is a very minor enhancement. >> --- >> tools/misc/xenwatchdogd.c | 20 ++++++++++++-------- >> 1 file changed, 12 insertions(+), 8 deletions(-) > > Throughout the series Signed-off-by: are missing from both you and Leigh. > The latter you may of course add only in case of this either having been > provided earlier (and dropped for an unknown reason), or with respective > agreement. Correction: I was misguided by the mention of someone else's name in the cover letter. It's really you who is the author aiui. And it's just that the S-o-b doesn't belong in the cover letter, but on every individual patch. Jan
diff --git a/tools/misc/xenwatchdogd.c b/tools/misc/xenwatchdogd.c index 2f7c822d61..d4da0ad0b6 100644 --- a/tools/misc/xenwatchdogd.c +++ b/tools/misc/xenwatchdogd.c @@ -9,9 +9,11 @@ #include <unistd.h> #include <signal.h> #include <stdio.h> +#include <stdbool.h> xc_interface *h; -int id = 0; +bool safeexit = false; +bool done = false; void daemonize(void) { @@ -38,20 +40,18 @@ void daemonize(void) void catch_exit(int sig) { - if (id) - xc_watchdog(h, id, 300); - exit(EXIT_SUCCESS); + done = true; } void catch_usr1(int sig) { - if (id) - xc_watchdog(h, id, 0); - exit(EXIT_SUCCESS); + safeexit = true; + done = true; } int main(int argc, char **argv) { + int id; int t, s; int ret; @@ -90,10 +90,14 @@ int main(int argc, char **argv) if (id <= 0) err(EXIT_FAILURE, "xc_watchdog setup"); - for (;;) { + while (!done) { sleep(s); ret = xc_watchdog(h, id, t); if (ret != 0) err(EXIT_FAILURE, "xc_watchdog"); } + + // Zero seconds timeout will disarm the watchdog timer + xc_watchdog(h, id, safeexit ? 0 : 300); + return 0; }
From: Leigh Brown <leigh@solinno.co.uk> Rework xenwatchdogd signal handling to do the minimum in the signal handler. This is a very minor enhancement. --- tools/misc/xenwatchdogd.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)