<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 8, 2016 at 2:28 PM, Raghavendra. H. R <span dir="ltr"><<a href="mailto:raghuhr84@gmail.com" target="_blank">raghuhr84@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:"times new roman",serif;font-size:large">Hi Tomasz,</div><div style="font-family:"times new roman",serif;font-size:large"><br></div><div 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 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 style="font-family:"times new roman",serif;font-size:large"><i><br></i></div><div style="font-family:"times new roman",serif;font-size:large"><span class="gmail-"><div>Below given is my Service file.</div><div><br></div></span><div><div><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><i><br></i></div><div><i>[Install]</i></div><div><i>WantedBy=multi-user.target</i></div></div></div><div style="font-family:"times new roman",serif;font-size:large"><i><br></i></div><div 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 style="font-family:"times new roman",serif;font-size:large"><br></div><div style="font-family:"times new roman",serif;font-size:large">This is error log</div><div style="font-family:"times new roman",serif;font-size:large"><br></div><div><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 style="font-family:"times new roman",serif;font-size:large"><br></div><div 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 style="font-family:"times new roman",serif;font-size:large"><br></div><div style="font-family:"times new roman",serif;font-size:large">MyApp code snippet</div><div style="font-family:"times new roman",serif;font-size:large"><br></div><div><div><font face="times new roman, serif" size="4">        <i>int count = 0;</i></font></div><div><font face="times new roman, serif" size="4"><i>        cpid = fork();</i></font></div><div><font face="times new roman, serif" size="4"><i><br></i></font></div><div><font face="times new roman, serif" size="4"><i>        if (cpid < 0)</i></font></div><div><font face="times new roman, serif" size="4"><i>        {</i></font></div><div><font face="times new roman, serif" size="4"><i>            printf("vfork failed.");</i></font></div><div><font face="times new roman, serif" size="4"><i>        }</i></font></div><div><font face="times new roman, serif" size="4"><i><br></i></font></div><div><font face="times new roman, serif" size="4"><i>        if (cpid == 0)</i></font></div><div><font face="times new roman, serif" size="4"><i>        {</i></font></div><div><font face="times new roman, serif" size="4"><i>            count++;</i></font></div><div><font face="times new roman, serif" size="4"><i>            if(count == 1)</i></font></div><div><font face="times new roman, serif" size="4"><i><span class="gmail-m_1872120327210583416gmail-Apple-tab-span" style="white-space:pre-wrap">                       </span>{</i></font></div></div></div></blockquote><div>This notificaiton is done by the child process, but notificaitons are accepted by default only form the main process. Read doc aobut "NotifyAccess=". <a href="https://www.freedesktop.org/software/systemd/man/systemd.service.html#NotifyAccess=">https://www.freedesktop.org/software/systemd/man/systemd.service.html#NotifyAccess=</a></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><font face="times new roman, serif" size="4"><i><span class="gmail-m_1872120327210583416gmail-Apple-tab-span" style="white-space:pre-wrap">                            </span>ret = sd_notify(0, "READY=1");</i></font></div><div><font face="times new roman, serif" size="4"><i><span class="gmail-m_1872120327210583416gmail-Apple-tab-span" style="white-space:pre-wrap">                                </span>printf("Return value = %d \n");</i></font></div><div><font face="times new roman, serif" size="4"><i><span class="gmail-m_1872120327210583416gmail-Apple-tab-span" style="white-space:pre-wrap">                       </span>}</i></font></div><div><font face="times new roman, serif" size="4"><i><span class="gmail-m_1872120327210583416gmail-Apple-tab-span" style="white-space:pre-wrap">               </span>}</i></font></div></div><div style="font-family:"times new roman",serif;font-size:large"><br></div><div style="font-family:"times new roman",serif;font-size:large"><br></div><div style="font-family:"times new roman",serif;font-size:large">Regards,</div><div style="font-family:"times new roman",serif;font-size:large">Raghavendra H R</div></div><div class="gmail_extra"><span class="gmail-"><br clear="all"><div><div class="gmail-m_1872120327210583416gmail_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></span><div><div class="gmail-h5"><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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>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><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>> 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><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="gmail-m_1872120327210583416HOEnZb"><font color="#888888"><br>
<br>
--<br>
Tomasz Torcz               "Never underestimate the bandwidth of a station<br>
xmpp: <a href="mailto:zdzichubg@chrome.pl" target="_blank">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" target="_blank">systemd-devel@lists.freedeskto<wbr>p.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></div></div>
<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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">







<p><span>Alessandro Puccetti</span></p></div></div>
</div></div>