<div dir="ltr"><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">Hi Tomasz,</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">Thanks for pointing out the mistake. I actually missed the line "Type=notify" in the mail.</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">I found the journalctl logs and from that I can make out the real problem is not about NOTIFY_SOCKET. It is about child process in my application <i>Myapp.</i></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><i><br></i></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><div class="gmail_default">Below given is my Service file.</div><div class="gmail_default"><br></div><div class="gmail_default"><div class="gmail_default"><div><i>[Unit]</i></div><div><i>Description=Sd_notify example</i></div><div><i><br></i></div><div><i>[Service]</i></div><div><i>Type=notify</i></div><div><i>ExecStart=/etc/Myapp</i></div></div><div class="gmail_default"><i><br></i></div><div class="gmail_default"><i>[Install]</i></div><div class="gmail_default"><i>WantedBy=multi-user.target</i></div></div></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><i><br></i></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">And in Myapp code my application is using fork() to create a child process. Because of which notification is not working correctly.</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">This is error log</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default"><i><font face="times new roman, serif" size="4">localhost systemd[1]: sd_example.service: Got notification message from PID 1270, but reception only permitted for main PID 1106</font><br></i></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">Is there any way from which we can force sd_notify to make use of Parent PID instead of child process. My sd_notify is after the fork() call, so I doubt sd_notify is called from child process.</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">MyApp code snippet</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default"><div class="gmail_default"><font face="times new roman, serif" size="4"> <i>int count = 0;</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i> cpid = fork();</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i><br></i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i> if (cpid < 0)</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i> {</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i> printf("vfork failed.");</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i> }</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i><br></i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i> if (cpid == 0)</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i> {</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i> count++;</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i> if(count == 1)</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>{</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ret = sd_notify(0, "READY=1");</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>printf("Return value = %d \n");</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>}</i></font></div><div class="gmail_default"><font face="times new roman, serif" size="4"><i><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>}</i></font></div></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">Regards,</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">Raghavendra H R</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><font style="font-family:times new roman,serif" size="2"></font><font face="times new roman,serif"><font size="4">--<br>Regards,<br><br>Raghavendra. H. R<br>(Raghu)</font><br></font></div></div></div></div>
<br><div class="gmail_quote">On Tue, Nov 8, 2016 at 5:15 PM, Tomasz Torcz <span dir="ltr"><<a href="mailto:tomek@pipebreaker.pl" target="_blank">tomek@pipebreaker.pl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Nov 08, 2016 at 05:01:59PM +0530, Raghavendra. H. R wrote:<br>
> Hi All,<br>
><br>
> I'm a newbie in Systemd init system and I'm exploring sd_notify which is<br>
> basically used for notification purpose in SystemD.<br>
<br>
</span> It is written “systemd” (all lowercase).<br>
<span class=""><br>
> I have created one unit file which is of type "notify" and in my<br>
> application I have written sd_notify(0, "READY=1"); from which SystemD can<br>
> be notified that my process in totally up and running.<br>
><br>
</span><span class="">> Below given is my Service file.<br>
><br>
</span>> *[Unit]*<br>
> *Description=Sd_notify example*<br>
><br>
> *[Service]*<br>
> *ExecStart=/etc/Myapp*<br>
<br>
<br>
This is not 'unit of type notify'. This is unit of type 'simple'.<br>
Please read "man systemd.service" and paragraph Type= and choose<br>
correctly.<br>
<span class=""><br>
<br>
> Need help in understanding what value should be set in the environment<br>
> varaible NOTIFY_SOCKET.<br>
> But there's no much information/documentation available on NOTIFY_SOCKET.<br>
<br>
</span> NOTIFY_SOCKET is filled-in by systemd and it is available when you<br>
correctly defined unit type. If you want to check it's value, you can<br>
user getenv() inside you program and print the value.<br>
I think amount of documentation about NOTIFY_SOCKET is enough, if<br>
you think there's something specific missing, let us know.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Tomasz Torcz "Never underestimate the bandwidth of a station<br>
xmpp: <a href="mailto:zdzichubg@chrome.pl">zdzichubg@chrome.pl</a> wagon filled with backup tapes." -- Jim Gray<br>
<br>
______________________________<wbr>_________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org">systemd-devel@lists.<wbr>freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/systemd-devel</a><br>
</font></span></blockquote></div><br></div>