[systemd-devel] Unable to store fds with systemd and reterive it back again

Tomasz Torcz tomek at pipebreaker.pl
Mon Jan 4 22:22:31 PST 2016


On Tue, Jan 05, 2016 at 01:11:16AM -0500, Pathangi Janardhanan 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);
>     syslog(LOG_NOTICE, "Result of sd notify %d", ret);
> 
>  From the debug printf I see
> Jan  5 00:37:23 ctoserver11 /usr/bin/myechoser[13640]: env. variable Notify
> Socket =/run/systemd/notify 19
> Jan  5 00:37:23 ctoserver11 /usr/bin/myechoser[13640]: Storing 1 number of
> fds
> Jan  5 00:37:23 ctoserver11 /usr/bin/myechoser[13640]: Result of sd notify
> -22
> 
> 
>  The return value seems to be -EINVAL, but looking at the code and the
> above debug, I am not sure why this is happening?
> 
>  Any help would be great.

  You need to set FileDescriptorStoreMax= to nonzero value in your service's
unit file.  See man systemd.service


-- 
Tomasz Torcz            There exists no separation between gods and men:
xmpp: zdzichubg at chrome.pl   one blends softly casual into the other.



More information about the systemd-devel mailing list