These pieces of code:
https://github.com/bitcoin/bitcoin/blob/8ab4f282c06d67074b872dbda0be37636fdd5186/src/util/system.cpp#L302
and
https://github.com/bitcoin/bitcoin/blob/8ab4f282c06d67074b872dbda0be37636fdd5186/src/util/system.cpp#L864
do not work as expected because they are called before the `InitLogging()` call.

{
    return AbsPathForConfigVal(fs::path(gArgs.GetArg("-pid", BITCOIN_PID_FILENAME)));
}
NODISCARD static bool CreatePidFile()
{
    FILE* file = fsbridge::fopen(GetPidFile(), "w");
    if (file) {
#ifdef WIN32
        fprintf(file, "%d\n", GetCurrentProcessId());
#else
        fprintf(file, "%d\n", getpid());
#endif
        fclose(file);
        return true;
    } else {
        return InitError(strprintf(_("Unable to create the PID file '%s': %s"), GetPidFile().string(), std::strerror(errno)));
    }
}
/**
 * This is a minimally invasive approach to shutdown on LevelDB read errors from the
 * chainstate, while keeping user interface out of the common library, which is shared
 * between bitcoind, and bitcoin-qt and non-server tools.
*/
class CCoinsViewErrorCatcher final : public CCoinsViewBacked