@omar Not sure what you mean by "unskippable infinite time-out"? #FreeBSD's #shutdown will send SIGKILL to daemons that don't die eventually. Making it reliable just means to a) make sure this won't happen by handling #SIGTERM as quick as possible (here I close all client connections and do the necessary cleanup like remove the pidfile) and b) recover gracefully from when it happened nevertheless (e.g. detect whether a #pidfile is stale, possible to do reliably by proper locking, and then remove it on startup).
BTW, the daemon currently weighs in at roughly 30k loc in #C, including bundled dependencies and build tooling. Very little of that is spent on "best practices daemon behavior" (and it could be reduced further by e.g. using the BSD's daemon(3) function, but that would sacrifice portability).


