Skip to main content

detached

Detach the current process in the background (daemonize).

def detached(
logfile: str = None,
pidfile: str = None,
uid: int, str = None,
gid: int, str = None,
umask: str, int = 0,
workdir: str = None,
fake: bool = False,
**opts: Any
) - > DaemonContext

Detach the current process in the background (daemonize).

Parameters

NameTypeDescription
logfilestr = NoneOptional path to a log file; the function verifies write access to this path before detaching.
pidfilestr = NoneOptional path to a PID file; the process will exit if a lock exists for a currently running PID.
uidint, str = NoneOptional user ID or username used to set the effective user privileges of the child process.
gidint, str = NoneOptional group ID or group name used to set the effective group privileges of the child process.
umaskstr, int = 0Optional file mode creation mask to be applied in the child process.
workdirstr = NoneThe working directory to change to after detaching; defaults to the current working directory.
fakebool = FalseIf True, the process will not actually detach; this is intended for debugging purposes.
**optsAnyAdditional keyword arguments that are ignored by the function.

Returns

TypeDescription
DaemonContextA context manager that handles the transition of the current process into a background daemon process.