systemd.daemon module

daemon.LISTEN_FDS_START = 3
systemd.daemon._listen_fds(unset_environment=True) → int

Return the number of descriptors passed to this process by the init system as part of the socket-based activation logic. Wraps sd_listen_fds(3).

systemd.daemon._is_fifo(fd, path) → bool

Returns True iff the descriptor refers to a FIFO or a pipe. Wraps sd_is_fifo(3).

systemd.daemon._is_socket(fd, family=AF_UNSPEC, type=0, listening=-1) → bool

Returns True iff the descriptor refers to a socket. Wraps sd_is_socket(3).

Constants for family are defined in the socket module.

systemd.daemon._is_socket_unix(fd, type, listening, path) → bool

Wraps sd_is_socket_unix(3).

systemd.daemon._is_socket_inet(fd, family=AF_UNSPEC, type=0, listening=-1, port=0) → bool

Wraps sd_is_socket_inet(3).

Constants for family are defined in the socket module.

systemd.daemon._is_mq(fd, path) → bool

Returns True iff the descriptor refers to a POSIX message queue. Wraps sd_is_mq(3).

systemd.daemon.notify(status, unset_environment=False, pid=0, fds=None) → bool

Send a message to the init system about a status change. Wraps sd_notify(3).

systemd.daemon.booted() → bool

Return True iff this system is running under systemd. Wraps sd_booted(3).

systemd.daemon.is_fifo(fileobj, path=None)[source]
systemd.daemon.is_mq(fileobj, path=None)[source]
systemd.daemon.is_socket(fileobj, family=0, type=0, listening=-1)[source]
systemd.daemon.is_socket_inet(fileobj, family=0, type=0, listening=-1, port=0)[source]
systemd.daemon.is_socket_sockaddr(fileobj, address, type=0, flowinfo=0, listening=-1)[source]

Check socket type, address and/or port, flowinfo, listening state.

Wraps sd_is_socket_inet_sockaddr(3).

address is a systemd-style numerical IPv4 or IPv6 address as used in ListenStream=. A port may be included after a colon (”:”). See systemd.socket(5) for details.

Constants for family are defined in the socket module.

systemd.daemon.is_socket_unix(fileobj, type=0, listening=-1, path=None)[source]
systemd.daemon.listen_fds(unset_environment=True)[source]

Return a list of socket activated descriptors

Example:

(in primary window)
$ systemd-activate -l 2000 python3 -c \
    'from systemd.daemon import listen_fds; print(listen_fds())'
(in another window)
$ telnet localhost 2000
(in primary window)
...
Execing python3 (...)
[3]