Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Daemonize ¶
Daemonize re-executes the current binary as a background process. The parent process exits after the child starts successfully. Returns true if this is the daemon child process, false if parent.
func StatusDaemon ¶
StatusDaemon checks if the daemon is running.
func StopDaemon ¶
StopDaemon sends SIGTERM to the process in the PID file.
H-9: verify the recorded PID actually belongs to a labyrinth process before signalling. Without this guard, a stale PID file (after crash + PID reuse) or an attacker-planted PID file lets `labyrinth daemon stop` SIGTERM an arbitrary process. We accept either /proc/<pid>/comm containing "labyrinth" or, if /proc is unavailable, a liveness probe via signal 0 (best-effort match — the kill primitive is still bounded because the parent CLI tool runs as the same user as the daemon, but the cmdline check makes accidental kills impossible on Linux).
func WritePID ¶
WritePID writes the current process ID to the given file path.
H-9: open with the platform's most-restrictive flags so a pre-planted symlink at the PID-file path cannot redirect this write to an arbitrary target (the historical /var/run TOCTOU). On systems that support it, O_NOFOLLOW prevents traversal of a symlink at the destination; we always truncate explicitly via O_TRUNC. Mode 0640 (was 0644) keeps the file readable by the service group only.
Types ¶
This section is empty.