import struct
from billiard.compat import close_open_fds as close_open_fds, get_fdmax as get_fdmax
from collections import namedtuple
from typing import Any, Optional

EX_OK: Any
EX_FAILURE: int
EX_UNAVAILABLE: Any
EX_USAGE: Any
SYSTEM: Any
IS_macOS: Any
IS_WINDOWS: Any

_range = namedtuple('_range', ['start', 'stop'])
SIGMAP: Any

def isatty(fh: Any): ...
def pyimplementation(): ...

class LockFailed(Exception): ...

class Pidfile:
    path: Any = ...
    def __init__(self, path: Any) -> None: ...
    def acquire(self): ...
    __enter__: Any = ...
    def is_locked(self): ...
    def release(self, *args: Any) -> None: ...
    __exit__: Any = ...
    def read_pid(self): ...
    def remove(self) -> None: ...
    def remove_if_stale(self): ...
    def write_pid(self) -> None: ...
PIDFile = Pidfile

def create_pidlock(pidfile: Any): ...
def fd_by_path(paths: Any): ...

class DaemonContext:
    workdir: Any = ...
    umask: Any = ...
    fake: Any = ...
    after_chdir: Any = ...
    after_forkers: Any = ...
    stdfds: Any = ...
    def __init__(self, pidfile: Optional[Any] = ..., workdir: Optional[Any] = ..., umask: Optional[Any] = ..., fake: bool = ..., after_chdir: Optional[Any] = ..., after_forkers: bool = ..., **kwargs: Any) -> None: ...
    def redirect_to_null(self, fd: Any) -> None: ...
    def open(self) -> None: ...
    __enter__: Any = ...
    def close(self, *args: Any) -> None: ...
    __exit__: Any = ...

def detached(logfile: Optional[Any] = ..., pidfile: Optional[Any] = ..., uid: Optional[Any] = ..., gid: Optional[Any] = ..., umask: int = ..., workdir: Optional[Any] = ..., fake: bool = ..., **opts: Any): ...
def parse_uid(uid: Any): ...
def parse_gid(gid: Any): ...
def setgroups(groups: Any): ...
def initgroups(uid: Any, gid: Any): ...
def setgid(gid: Any) -> None: ...
def setuid(uid: Any) -> None: ...
def maybe_drop_privileges(uid: Optional[Any] = ..., gid: Optional[Any] = ...) -> None: ...

class Signals:
    ignored: Any = ...
    default: Any = ...
    def arm_alarm(self, seconds: Any) -> None: ...
    def arm_alarm(self, seconds: Any) -> None: ...
    def arm_alarm(self, seconds: Any): ...
    def reset_alarm(self): ...
    def supported(self, name: Any): ...
    def signum(self, name: Any): ...
    def reset(self, *signal_names: Any) -> None: ...
    def ignore(self, *names: Any) -> None: ...
    def __getitem__(self, name: Any): ...
    def __setitem__(self, name: Any, handler: Any) -> None: ...
    def update(self, _d_: Optional[Any] = ..., **sigmap: Any) -> None: ...

signals: Any

def signal_name(signum: Any): ...
def set_process_title(progname: Any, info: Optional[Any] = ...): ...
def set_mp_process_title(*a: Any, **k: Any) -> None: ...
def get_errno_name(n: Any): ...
def ignore_errno(*errnos: Any, **kwargs: Any) -> None: ...
pack = struct.pack
unpack = struct.unpack
unpack_from = struct.unpack_from
