Commit graph

12 commits

Author SHA1 Message Date
Lennart Poettering 31021ba085 sd-daemon: Simplify sd_booted() check
We can just use access() to check whether /run/system/system/ is a
directory, no need to involve stat(). The trick is to suffix the path
name with a dash.
2015-09-29 21:55:51 +02:00
Maciej Wereski a5bd3c32ab sd_pid_notify_with_fds: fix computing msg_controllen
CMSG_SPACE(0) may return value other than 0. This caused sendmsg to fail
with EINVAL, when have_pid or n_fds was 0.
2015-09-09 14:28:43 +02:00
Zbigniew Jędrzejewski-Szmek e680380168 sd-daemon: return EBADF for invalid fd numbers
This matches what open(2) and other system functions do.
2015-08-07 11:30:18 -04:00
Zbigniew Jędrzejewski-Szmek 64144440a5 sd-daemon: simplify sd_pid_notify_with_fds
Coverity was complaining that CMSG_NXTHDR is used without
checking the return value. In this case it cannot fail, but
it is a good excuse to simplify the function a bit.

CID #1261726.
2015-03-13 23:42:17 -04:00
Lennart Poettering d4a144fadf sd-daemon: replace VLA with alloca(), to make llvm happy
https://bugs.freedesktop.org/show_bug.cgi?id=89379
2015-03-02 20:55:38 +01:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
This patch removes includes that are not used. The removals were found with
include-what-you-use which checks if any of the symbols from a header is
in use.
2015-02-23 23:53:42 +01:00
Lennart Poettering a354329f72 core: add new logic for services to store file descriptors in PID 1
With this change it is possible to send file descriptors to PID 1, via
sd_pid_notify_with_fds() which PID 1 will store individually for each
service, and pass via the usual fd passing logic on next invocation.
This is useful for enable daemon reload schemes where daemons serialize
their state to /run, push their fds into PID 1 and terminate, restoring
their state on next start from the data in /run and passed in from PID
1.

The fds are kept by PID 1 as long as no POLLHUP or POLLERR is seen on
them, and the service they belong to are either not dead or failed, or
have a job queued.
2015-01-06 03:16:39 +01:00
Zbigniew Jędrzejewski-Szmek a9becdd65b sd-daemon,man: ignore missing $WATCHDOG_PID
Systemd 209 started setting $WATCHDOG_PID, and sd-daemon watch was
modified to check for this variable. This means that
sd_watchdog_enabled() stopped working with previous versions of
systemd. But sd-event is a public library and API and we must keep it
working even when a program compiled with a newer version of the
libary is used on a system running an older version of the manager.

getenv() and unsetenv() are fairly expensive calls, so optimize
sd_watchdog_enabled() by not calling them when unnecessary.

man: centralize the description of $WATCHDOG_PID and $WATCHDOG_USEC in
the sd_watchdog_enabled manpage. It is better not to repeat the same
stuff in two places.
2014-10-23 00:17:18 -04:00
Lennart Poettering 3cb4674019 libsystemd: make use of our common sockaddr_union everywhere 2014-07-10 21:16:40 +02:00
Lennart Poettering be8f4e9e8e sd-daemon: introduce sd_pid_notify() and sd_pid_notifyf()
sd_pid_notify() operates like sd_notify(), however operates on a
different PID (for example the parent PID of a process).

Make use of this in systemd-notify, so that message are sent from the
PID specified with --pid= rather than the usually shortlived PID of
systemd-notify itself.

This should increase the likelyhood that PID 1 can identify the cgroup
that the notification message was sent from properly.
2014-06-05 17:05:18 +02:00
Lennart Poettering 56dc9aec21 sd-daemon: fix incorrect variable access 2014-03-24 23:54:14 +01:00
Kay Sievers 0ebee88184 build-sys: merge libsystemd-daemon into libsystemd 2014-02-19 01:09:19 +01:00
Renamed from src/libsystemd-daemon/sd-daemon.c (Browse further)