systemd: support sending file descriptors to systemd - #16864
Conversation
This is needed for future work (fdstore). Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #16864 +/- ##
==========================================
+ Coverage 77.63% 79.04% +1.41%
==========================================
Files 1361 1370 +9
Lines 189322 190687 +1365
Branches 2446 2465 +19
==========================================
+ Hits 146971 150733 +3762
+ Misses 33478 30872 -2606
- Partials 8873 9082 +209
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Wed Apr 29 07:01:52 UTC 2026 Failures:Executing:
Skipped tests from snapd-testing-skipIf you wish to have any of the below tests run in your PR, in your PR description, add 'unskip:' followed by a copy-and-pasted list (without variants) of the below tests you wish to run (unskip plus test list must be valid yaml)
|
zyga
left a comment
There was a problem hiding this comment.
Looks good, just a few inline comments.
| if err != nil { | ||
| return err | ||
| } | ||
| // TODO: keep it open to avoid re-opening and make sure to have O_CLOEXEC |
There was a problem hiding this comment.
Ditto, think cloexec + close is correct.
zyga
left a comment
There was a problem hiding this comment.
One more comment on API design.
use *os.File instead of raw fds to avoid potential race with go GC. Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
| // descriptors associated with passed files to systemd. | ||
| // | ||
| // inspired by libsystemd/sd-daemon/sd-daemon.c from the systemd source | ||
| func SdNotifyWithFds(notifyState string, files ...*os.File) error { |
There was a problem hiding this comment.
what files would be sent with FDSTOREREMOVE=1 ?
There was a problem hiding this comment.
zyga
left a comment
There was a problem hiding this comment.
Quick pass, two points inline.
| return err | ||
| } | ||
|
|
||
| // SdNotifyWithFds sends the given state string notification and file |
There was a problem hiding this comment.
Do you think this should be private and we should have a number of public wappers that call it with specific value of notifyState?
There was a problem hiding this comment.
it's a systemd primitive that might be used in different packages like SdNotify, also trying to follow libsystemd
| } | ||
|
|
||
| // SdNotifyWithFds sends the given state string notification and file | ||
| // descriptors associated with passed files to systemd. |
There was a problem hiding this comment.
Use
SdNotifyto send fd removal requests.
There was a problem hiding this comment.
SdNotifyWithFds could be used to send fds to systemd unrelated to the fdstore
zyga
left a comment
There was a problem hiding this comment.
Clarified location of keep-alive call
Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
This is needed for future work (split from fdstore #16784).