util: Add RAII TokenPipe
shutdown: Use RAII TokenPipe in shutdown
bitcoind: Add -daemonwait option to wait for initialization
This adds a -daemonwait flag that does the same as -daemon except
it, from a user perspective, backgrounds the process only after
initialization is complete.This can be useful when the process launching bitcoind wants to
guarantee that either the RPC server is running, or that initialization
failed, before continuing. The exit code indicates the initialization
result.This replaces the use of the libc function daemon() by a custom
implementation which is inspired by the glibc implementation, but also
creates a pipe from the child to the parent process for communication.An additional advantage of having our own daemon() implementation is
that no MACOS-specific pragmas are needed anymore to silence a
deprecation warning.
Always add -daemonwait to known command line arguments
This is a backport of core#21007 and core#21447