WATCHDOG(9)
πΆ WATCHDOG(9) β the kernel dev's manual, bestie edition π
okay so you found the watchdog page, which lives in section 9 of the Kernel Developer's Manual β¨ (yes, the dev one, we're in the big leagues now, no cap). Sit down, grab a strawberry π, and let's talk about making sure your system never just... vibes into the void forever.
β¨ NAME β¨
watchdog β the software and hardware watchdog facility ππ¦Ίπ₯
it's giving "someone to check on you when you stop responding." main character energy, honestly.
π SYNOPSIS π
#include <sys/watchdog.h>
void
watchdog_fn(void *private, u_int cmd, int *error);
EVENTHANDLER_REGISTER(watchdog_list, watchdog_fn, private, 0);
EVENTHANDLER_DEREGISTER(watchdog_list, eventhandler_tag);
look at that. three lines. one function. we love a low-effort registration π
πΈ DESCRIPTION πΈ
okay so here's the whole vibe: to implement a watchdog in software or hardware, you literally only need to write a single function and register it on the global watchdog_list. that's it. one function. iconic behavior, truly.
that function has to look at the cmd argument and act on it like this:
- if
cmdis zero, the watchdog must be disabled, and theerrorargument gets left untouched. do not touch it. hands off. π but β and this is the important part β if the watchdog cannot be disabled, thenerrormust be set toEOPNOTSUPP. periodt. - else (so, anything non-zero), the watchdog should be reset and configured to a timeout of
(1 << (cmd & WD_INTERVAL))nanoseconds or larger, and theerrorargument should be set to zero to signal that a watchdog has been armed. π₯ consider it locked and loaded. - if the watchdog cannot be configured to the proposed timeout, it must be disabled and the
errorargument left as is. why, you ask? to avoid hiding the arming of another watchdog. bestie we are NOT stealing someone else's spotlight π
real talk though: there is no specification of what the watchdog should do when it times out. none. it's giving "your call, king." but a hardware reset or similar "drastic but certain" behaviour is recommended β and honestly, if you're gonna go, go loud. π₯
π¦ SEE ALSO π¦
π AUTHORS π
the watchdog facility and this manual page were written by Poul-Henning Kamp <phk@FreeBSD.org>. absolute legend, we thank them for their service π«Ά
and that's the whole page, bestie β go forth and register your watchdog_fn, keep those error values honest, and never leave a watchdog unarmed. iykyk π
this edition came from Debian, dated February 28, 2004 β old school, but the vibes are timeless. mwah π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2004 Poul-Henning Kamp <phk@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms