<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Aug 3, 2018 at 8:57 PM Rajesh Kumar <<a href="mailto:myemail.rajeshkumar@gmail.com">myemail.rajeshkumar@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span style="color:rgb(31,77,120)">Hi All,<span></span></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span style="color:rgb(31,77,120)"><span> </span></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span style="color:rgb(31,77,120)">We are facing issue in on system services.<span></span></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span style="color:rgb(31,77,120)"><span> </span></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span style="color:rgb(31,77,120)">Problem statement:<span></span></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span style="color:rgb(31,77,120)">We have two process P1 and P2, both are getting daemonize using fork() command and parent exits immediately after fork().<span></span></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span style="color:rgb(31,77,120)">We want process P2 to start once P1 is initialized successfully (means P2 should start when P1 is listening on particular socket and in ready state to handle request)<span></span></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span> </span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><font color="#1f4d78">[...]</font></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span> </span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;text-decoration-style:initial;text-decoration-color:initial;font-size:11pt;font-family:Calibri,sans-serif"><span style="color:rgb(31,77,120)">Our processes P1 and P2 which are started through service file are also getting demonized using fork(). And, we have used sd_notify() mechanisum to notify systemd once process initialization completes.</span></p></div></blockquote><div><br></div><div>With Type=forking, the service is considered "ready" when the parent exits. So if you use Type=forking, make sure the parent *doesn't* exit until the child has fully initialized. (For example, use a pipe or an eventfd between child and parent.)</div><div><br></div><div>But with Type=notify, there is no reason to perform daemonization at all. (Could almost say that daemonization isn't even *supported* for this type...) If you use Type=notify, just do everything directly in the parent.</div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div></div>