#pragma once // Minimal sd_listen_fds(3) reimplementation — one function, no libsystemd dependency, for // the one fd velox.socket ever hands us. See velox.socket / velox.service in // packaging/nativehost's systemd unit pair: the socket unit binds // $XDG_RUNTIME_DIR/velox/velox.sock itself (before veloxd ever runs, so the very first // connection attempt after boot is queued by the kernel rather than refused) and execs // veloxd with that listening fd already open at fd 3, LISTEN_FDS=1, LISTEN_PID=. namespace velox::daemon::rpc { // The systemd-activated listening socket fd, or -1 if this process was not socket- // activated (LISTEN_PID doesn't match our pid, or LISTEN_FDS is unset/not exactly 1 — more // than one would mean a unit file mismatch, since veloxd only ever asks for one socket). // Clears LISTEN_PID/LISTEN_FDS from the environment on the way out either way, per // sd_listen_fds's own contract, so a value meant for us is never mistaken for one meant for // a process veloxd might itself exec later. int systemd_activated_fd(); } // namespace velox::daemon::rpc