watchdog: stop watchdog first on startup
authorMatt Spinler <mspinler@linux.vnet.ibm.com>
Sat, 8 Jul 2017 16:35:25 +0000 (18:35 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 8 Jul 2017 16:35:25 +0000 (18:35 +0200)
commit31c765081dc41f158786545fbea9294be4685bd2
tree902b029ed3d2167743692cdcd2c941e7617c066b
parent1b84f4a22adb1a8c3fa633a5b08081694667505c
watchdog: stop watchdog first on startup

Some watchdog implementations may do things other than issue
a reboot on a watchdog timeout.  In this case, there's the
possibility of restarting this program from the state of
the watchdog device not being properly stopped (done by writing
a 'V' and closing the device).  Since it wasn't stopped, the
driver may not be able to restart the watchdog when this program
reopens it and starts pinging it.

To fix this, the code will always first issue the stop when it
starts up.

function                                             old     new   delta
shutdown_on_signal                                     -      32     +32
watchdog_main                                        268     298     +30
shutdown_watchdog                                      -      25     +25
watchdog_shutdown                                     41       -     -41
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/0 up/down: 87/-41)             Total: 46 bytes

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/watchdog.c