daemon: add SdNotifyMonotonicUsec
helper function
#435
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The synchronized service reload protocol added in systemd version 253 requires that the service provides a
MONOTONIC_USEC
field alongside theRELOADING=1
notification message for synchronization purposes. The value carried in this field must be the systemCLOCK_MONOTONIC
timestamp at the time the notification message was generated as systemd compares it to otherCLOCK_MONOTONIC
timestamps taken by pid1.While the Go standard library does utilize
CLOCK_MONOTONIC
in the implementation of package "time", the absolute monotonic timestamps intime.Time
values are not made available to programmers. Users familiar with idiomatic usage of monotonic timestamps in Go might (incorrectly) try to implementMONOTONIC_USEC
using process-relative monotonic timestamps, like so:Help users fall into the pit of success by providing a helper function
SdNotifyMonotonicUsec()
which returns aMONOTONIC_USEC
string which encodes the systemCLOCK_MONOTONIC
timestamp in decimal microseconds, as systemd expects.