[systemd-devel] Unable to store fds with systemd and reterive it back again
Lennart Poettering
lennart at poettering.net
Tue Jan 5 04:00:50 PST 2016
On Tue, 05.01.16 01:11, Pathangi Janardhanan (path.jana at gmail.com) wrote:
> Hi,
>
> I am using the function sd_pid_notify_with_fds and am unable to store the
> fds with systemd. My service is a simple echo server,
> and here is the snippet of code that is being called to store the FDS. I
> have also included the debug code.
>
> // Store the FDs with systemd
> e = getenv("NOTIFY_SOCKET");
> if (e == NULL) {
> syslog(LOG_NOTICE, "environment variable Notify socket is null");
> } else {
> syslog(LOG_NOTICE, "env. variable Notify Socket =%s %d", e,
> strlen(e));
> }
>
> syslog(LOG_NOTICE, "Storing %d number of fds", num_fd);
> ret = sd_pid_notify_with_fds(0, 0, "FDSTORE=1\n", (const int *) fd,
> num_fd);
Is "fd" a single fd? If so you need to pass this as &fd of course...
The FDSTORE=1 line doesn't need to be suffixed with "\n" btw (but it
doesn't hurt if you do...)
It might be worth strace'ing your process to see that the right
sendmsg() call is issued. If in doubt, strace this specific code
snippet and paste the sendmsg() line here.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list