From: Zbigniew Jędrzejewski-Szmek Date: Fri, 15 Sep 2023 06:10:13 +0000 (+0200) Subject: man/sd_notify: split out variable descriptions to a separate section X-Git-Tag: v255-rc1~510^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ef86486acf992845cbdc2ee583e7348edf1a9b19;p=thirdparty%2Fsystemd.git man/sd_notify: split out variable descriptions to a separate section This just moves the text around with miminal text added to refer to the new section. --- diff --git a/man/sd_notify.xml b/man/sd_notify.xml index b4067410376..a0f28703c48 100644 --- a/man/sd_notify.xml +++ b/man/sd_notify.xml @@ -109,8 +109,69 @@ The state parameter should contain a newline-separated list of variable assignments, similar in style to an environment block. A trailing newline is implied if none is - specified. The string may contain any kind of variable assignments, but the following shall be considered - well-known: + specified. The string may contain any kind of variable assignments, but see the next section + for a list of assignments understood by the service manager. + + Note that systemd will accept status data sent from a service only if the + NotifyAccess= option is correctly set in the service definition file. See + systemd.service5 for + details. + + Note that sd_notify() notifications may be attributed to units correctly only + if either the sending process is still around at the time PID 1 processes the message, or if the sending + process is explicitly runtime-tracked by the service manager. The latter is the case if the service + manager originally forked off the process, i.e. on all processes that match + NotifyAccess= or + NotifyAccess=. Conversely, if an auxiliary process of the unit + sends an sd_notify() message and immediately exits, the service manager might not be + able to properly attribute the message to the unit, and thus will ignore it, even if + NotifyAccess= is set for it. + + Hence, to eliminate all race conditions involving lookup of the client's unit and attribution of + notifications to units correctly, sd_notify_barrier() may be used. This call acts as + a synchronization point and ensures all notifications sent before this call have been picked up by the + service manager when it returns successfully. Use of sd_notify_barrier() is needed + for clients which are not invoked by the service manager, otherwise this synchronization mechanism is + unnecessary for attribution of notifications to the unit. + + sd_notifyf() is similar to sd_notify() but takes a + printf()-like format string plus arguments. + + sd_pid_notify() and sd_pid_notifyf() are similar to + sd_notify() and sd_notifyf() but take a process ID (PID) to use + as originating PID for the message as first argument. This is useful to send notification messages on + behalf of other processes, provided the appropriate privileges are available. If the PID argument is + specified as 0, the process ID of the calling process is used, in which case the calls are fully + equivalent to sd_notify() and sd_notifyf(). + + sd_pid_notify_with_fds() is similar to sd_pid_notify() + but takes an additional array of file descriptors. These file descriptors are sent along the notification + message to the service manager. This is particularly useful for sending FDSTORE=1 + messages, as described above. The additional arguments are a pointer to the file descriptor array plus + the number of file descriptors in the array. If the number of file descriptors is passed as 0, the call + is fully equivalent to sd_pid_notify(), i.e. no file descriptors are passed. Note + that file descriptors sent to the service manager on a message without FDSTORE=1 are + immediately closed on reception. + + sd_pid_notifyf_with_fds() is a combination of + sd_pid_notify_with_fds() and sd_notifyf(), i.e. it accepts both + a PID and a set of file descriptors as input, and processes a format string to generate the state + string. + + sd_notify_barrier() allows the caller to synchronize against reception of + previously sent notification messages and uses the BARRIER=1 command. It takes a + relative timeout value in microseconds which is passed to + ppoll2 + . A value of UINT64_MAX is interpreted as infinite timeout. + + sd_pid_notify_barrier() is just like sd_notify_barrier(), + but allows specifying the originating PID for the notification message. + + + + Well-known assignments + + The following assignments have a defined meaning: @@ -126,9 +187,9 @@ RELOADING=1 - Tells the service manager that the service is beginning to reload its - configuration. This is useful to allow the service manager to track the service's internal state, and - present it to the user. Note that a service that sends this notification must also send a + Tells the service manager that the service is beginning to reload its configuration. + This is useful to allow the service manager to track the service's internal state, and present it to + the user. Note that a service that sends this notification must also send a READY=1 notification when it completed reloading its configuration. Reloads the service manager is notified about with this mechanisms are propagated in the same way as they are when originally initiated through the service manager. This message is particularly relevant for @@ -138,6 +199,16 @@ + + STOPPING=1 + + Tells the service manager that the service is beginning its shutdown. This is useful + to allow the service manager to track the service's internal state, and present it to the user. + + + + + MONOTONIC_USEC=… @@ -151,24 +222,13 @@ - - STOPPING=1 - - Tells the service manager that the service is beginning its shutdown. This is useful - to allow the service manager to track the service's internal state, and present it to the - user. - - - - STATUS=… Passes a single-line UTF-8 status string back to the service manager that describes the service state. This is free-form and can be used for various purposes: general state feedback, fsck-like programs could pass completion percentages and failing programs could pass a human-readable - error message. Example: STATUS=Completed 66% of file system - check… + error message. Example: STATUS=Completed 66% of file system check… @@ -179,8 +239,8 @@ Reset the access to the service status notification socket during runtime, overriding NotifyAccess= setting in the service unit file. See systemd.service5 - for details, specifically NotifyAccess= for a list of accepted - values. + for details, specifically NotifyAccess= for a list of accepted values. + @@ -216,7 +276,7 @@ MAINPID=… The main process ID (PID) of the service, in case the service manager did not fork - off the process itself. Example: MAINPID=4711 + off the process itself. Example: MAINPID=4711. @@ -361,63 +421,8 @@ - It is recommended to prefix variable names that are not listed above with X_ to + It is recommended to prefix variable names that are not listed above with X_ to avoid namespace clashes. - - Note that systemd will accept status data sent from a service only if the - NotifyAccess= option is correctly set in the service definition file. See - systemd.service5 for - details. - - Note that sd_notify() notifications may be attributed to units correctly only - if either the sending process is still around at the time PID 1 processes the message, or if the sending - process is explicitly runtime-tracked by the service manager. The latter is the case if the service - manager originally forked off the process, i.e. on all processes that match - NotifyAccess= or - NotifyAccess=. Conversely, if an auxiliary process of the unit - sends an sd_notify() message and immediately exits, the service manager might not be - able to properly attribute the message to the unit, and thus will ignore it, even if - NotifyAccess= is set for it. - - Hence, to eliminate all race conditions involving lookup of the client's unit and attribution of - notifications to units correctly, sd_notify_barrier() may be used. This call acts as - a synchronization point and ensures all notifications sent before this call have been picked up by the - service manager when it returns successfully. Use of sd_notify_barrier() is needed - for clients which are not invoked by the service manager, otherwise this synchronization mechanism is - unnecessary for attribution of notifications to the unit. - - sd_notifyf() is similar to sd_notify() but takes a - printf()-like format string plus arguments. - - sd_pid_notify() and sd_pid_notifyf() are similar to - sd_notify() and sd_notifyf() but take a process ID (PID) to use - as originating PID for the message as first argument. This is useful to send notification messages on - behalf of other processes, provided the appropriate privileges are available. If the PID argument is - specified as 0, the process ID of the calling process is used, in which case the calls are fully - equivalent to sd_notify() and sd_notifyf(). - - sd_pid_notify_with_fds() is similar to sd_pid_notify() - but takes an additional array of file descriptors. These file descriptors are sent along the notification - message to the service manager. This is particularly useful for sending FDSTORE=1 - messages, as described above. The additional arguments are a pointer to the file descriptor array plus - the number of file descriptors in the array. If the number of file descriptors is passed as 0, the call - is fully equivalent to sd_pid_notify(), i.e. no file descriptors are passed. Note - that file descriptors sent to the service manager on a message without FDSTORE=1 are - immediately closed on reception. - - sd_pid_notifyf_with_fds() is a combination of - sd_pid_notify_with_fds() and sd_notifyf(), i.e. it accepts both - a PID and a set of file descriptors as input, and processes a format string to generate the state - string. - - sd_notify_barrier() allows the caller to synchronize against reception of - previously sent notification messages and uses the BARRIER=1 command. It takes a - relative timeout value in microseconds which is passed to - ppoll2 - . A value of UINT64_MAX is interpreted as infinite timeout. - - sd_pid_notify_barrier() is just like sd_notify_barrier(), - but allows specifying the originating PID for the notification message.