Skip to main content

Module daemon

Module daemon 

Source
Expand description

Unix daemonization for pwr-server.

Implements the classic double-fork daemonization pattern:

  1. Fork → parent exits, child continues
  2. setsid() to become session leader
  3. Second fork → child exits, grandchild continues (prevents re-acquisition of a controlling terminal)
  4. chdir(“/”), umask(0), redirect stdio to /dev/null
  5. Write PID file

Constants§

SYSTEM_PID_FILE
Default path for the PID file written after successful daemonization (system-wide install).

Functions§

daemonize
Daemonize the current process.
pid_file_for_config
Given a config file path, return the appropriate PID file.
stop_daemon
Stop a running pwr-server daemon.
user_pid_file
Return the PID file path for a user-level install.