On 2024-04-13 11:16, Stefan Monnier wrote: >> Maybe some feedback on the Emacs side about this? There are indeed very >> few places where systemd sd_* functions are called in emacs.c, should we >> try and re-implement them instead of using the library as is? Would that >> be a contribution Emacs devs would be interested in? That would >> definitely be beneficial for Emacs on Guix as highlighted by Ludo'. > > It's hard to tell without seeing the actual patch. Seems to work properly on my side with the following patch, on Guix with the shepherd service I sent a few weeks ago. The patch is actually pretty simple. Some choices : - I removed most of the code in former function sd_listen_fds' upstream source code, because it didn't seem related to integration functionality with emacs but rather to systemd inner workings. Some edge cases might not be as well covered (strtol with defaults instead of systemd's safe_atoi), but it works on my side. The functionality is directly integrated in emacs.c rather than the function itself reproduced. - I simplified the sd_is_socket function to instead use the upstream untouched sd_is_socket_internal function. This is because the default family argument was set in emacs.c. - The sd_notify code is taken from https://www.freedesktop.org/software/systemd/man/devel/sd_notify.html#Notes Disclaimer : I'm not a seasoned C nor emacs developer, some things are probably odd, but I would need for feedback to make things more emacsy / rigorous in C.