summaryrefslogtreecommitdiff
path: root/src/systemd
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-06 00:26:25 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-06 03:16:39 +0100
commita354329f724d6ce913d2ccffb2be8f3327a67faa (patch)
treeb6b05cc2c42c274f8385a16b1896d6c88bf4fc8f /src/systemd
parent75399049653f2d5e22032da70cf96f20d7b4d9a6 (diff)
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.
Diffstat (limited to 'src/systemd')
-rw-r--r--src/systemd/sd-daemon.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/systemd/sd-daemon.h b/src/systemd/sd-daemon.h
index 351b4e59c..b878b4d8a 100644
--- a/src/systemd/sd-daemon.h
+++ b/src/systemd/sd-daemon.h
@@ -190,6 +190,12 @@ int sd_is_mq(int fd, const char *path);
timestamps to detect failed services. Also see
sd_watchdog_enabled() below.
+ FDSTORE=1 Store the file descriptors passed along with the
+ message in the per-service file descriptor store,
+ and pass them to the main process again on next
+ invocation. This variable is only supported with
+ sd_pid_notify_with_fds().
+
Daemons can choose to send additional variables. However, it is
recommended to prefix variable names not listed above with X_.
@@ -243,6 +249,13 @@ int sd_pid_notify(pid_t pid, int unset_environment, const char *state);
int sd_pid_notifyf(pid_t pid, int unset_environment, const char *format, ...) _sd_printf_(3,4);
/*
+ Similar to sd_pid_notify(), but also passes the specified fd array
+ to the service manager for storage. This is particularly useful for
+ FDSTORE=1 messages.
+*/
+int sd_pid_notify_with_fds(pid_t pid, int unset_environment, const char *state, const int *fds, unsigned n_fds);
+
+/*
Returns > 0 if the system was booted with systemd. Returns < 0 on
error. Returns 0 if the system was not booted with systemd. Note
that all of the functions above handle non-systemd boots just