Re: [systemd-devel] PIDFile creation logic

2021-10-19 Thread Ian Pilcher

On 10/18/21 16:56, Kenneth Porter wrote:

On 10/18/2021 1:08 PM, Silvio Knizek wrote:

OTOH, systemd-networkd itself has inbuilt NDPProxy capabilities.


How well does it coexist with RHEL/CentOS 7? I don't really understand 
how the various network management ecosystems interact. Pointers welcome.


systemd-networkd works just fine on EL7.  You'll need to install it from
EPEL, but that's about the only "difficult" thing about it.

--

 In Soviet Russia, Google searches you!




[systemd-devel] Antw: [EXT] [systemd‑devel] PIDFile creation logic

2021-10-19 Thread Ulrich Windl
>>> Kenneth Porter  schrieb am 18.10.2021 um 21:43 in
Nachricht <95B112234248FF54AD014623@[192.168.1.16]>:
> I just installed the new‑to‑EPEL ndppd service and am seeing this in my
log:
> 
> Oct 17 21:10:08 saruman systemd: Can't open PID file 
> /var/run/ndppd/ndppd.pid (yet?) after start: No such file or directory
> 
> Examining the source, I see that the pidfile is created by the child 
> process, not the parent. I'm guessing that systemd is expecting the pidfile

> to exist when the parent exits? (I want to file the issue on the upstream 
> program and want to make sure I understand how this should work.)
> 
> Source in question. Note how daemonize() forks and exits and main() invokes

> daemonize and then creates the pidfile. I'm thinking that daemonize() 
> should create the pidfile before it invokes exit().
> 
> 

I had the same incompatibility problem in my own daemon, and the fix was like
this (still somewhat inefficient):
...
else if ( pid == 0 )
{
/* wait for parent to exit */
while ( getppid() != 1 )
milli_sleep(5);
/* child continues */
...

Regards,
Ulrich





Re: [systemd-devel] PIDFile creation logic

2021-10-19 Thread Mantas Mikulėnas
On Tue, Oct 19, 2021, 08:45 Andrei Borzenkov  wrote:

> On 18.10.2021 23:08, Silvio Knizek wrote:
> > Am Montag, dem 18.10.2021 um 12:43 -0700 schrieb Kenneth Porter:
> >> I just installed the new-to-EPEL ndppd service and am seeing this in my
> log:
> >>
> >> Oct 17 21:10:08 saruman systemd: Can't open PID file
> >> /var/run/ndppd/ndppd.pid (yet?) after start: No such file or directory
> >>
>
> That is just an information. May be it could be downgraded to debug, at
> least initially.
>
> >> Examining the source, I see that the pidfile is created by the child
> >> process, not the parent. I'm guessing that systemd is expecting the
> pidfile
> >> to exist when the parent exits? (I want to file the issue on the
> upstream
> >> program and want to make sure I understand how this should work.)
> >>
> >> Source in question. Note how daemonize() forks and exits and main()
> invokes
> >> daemonize and then creates the pidfile. I'm thinking that daemonize()
> >> should create the pidfile before it invokes exit().
> >>
> >> 
> >>
> > Hi,
> >
> > just don't demonize and don't use a PIDFile= at all. systemd is
> > actually quite apt in figuring out which process is the right main one.
>
> It is not about "main process". It is about notifying systemd that your
> service is ready and systemd can proceed with After dependencies.
> Without PIDFile your service is "ready" as soon as it forked. This most
> likely is not correct.
>

Not quite as soon as it forked, but as soon as the parent exits.

This doesn't depend on pidfiles, and in general seems to be something that
services get right more often than pidfile creation. Initialize, fork, exit
in parent.


Re: [systemd-devel] PIDFile creation logic

2021-10-18 Thread Andrei Borzenkov
On 18.10.2021 23:08, Silvio Knizek wrote:
> Am Montag, dem 18.10.2021 um 12:43 -0700 schrieb Kenneth Porter:
>> I just installed the new-to-EPEL ndppd service and am seeing this in my log:
>>
>> Oct 17 21:10:08 saruman systemd: Can't open PID file
>> /var/run/ndppd/ndppd.pid (yet?) after start: No such file or directory
>>

That is just an information. May be it could be downgraded to debug, at
least initially.

>> Examining the source, I see that the pidfile is created by the child
>> process, not the parent. I'm guessing that systemd is expecting the pidfile
>> to exist when the parent exits? (I want to file the issue on the upstream
>> program and want to make sure I understand how this should work.)
>>
>> Source in question. Note how daemonize() forks and exits and main() invokes
>> daemonize and then creates the pidfile. I'm thinking that daemonize()
>> should create the pidfile before it invokes exit().
>>
>> 
>>
> Hi,
> 
> just don't demonize and don't use a PIDFile= at all. systemd is
> actually quite apt in figuring out which process is the right main one.

It is not about "main process". It is about notifying systemd that your
service is ready and systemd can proceed with After dependencies.
Without PIDFile your service is "ready" as soon as it forked. This most
likely is not correct.

Whether service developers are actually careful to only create PID file
at the right time is unknown.

If nothing depends on service availability Type=simple is easier.

> Also, the ndppd 0.2.5 release is 10 years old and doesn't look
> maintained anymore.
> OTOH, systemd-networkd itself has inbuilt NDPProxy capabilities.
> 
> BR
> Silvio
> 



Re: [systemd-devel] PIDFile creation logic

2021-10-18 Thread Kenneth Porter

On 10/18/2021 1:08 PM, Silvio Knizek wrote:

OTOH, systemd-networkd itself has inbuilt NDPProxy capabilities.


How well does it coexist with RHEL/CentOS 7? I don't really understand 
how the various network management ecosystems interact. Pointers welcome.





Re: [systemd-devel] PIDFile creation logic

2021-10-18 Thread Cristian Rodríguez
On Mon, Oct 18, 2021 at 4:44 PM Kenneth Porter  wrote:
>
> I just installed the new-to-EPEL ndppd service and am seeing this in my log:
>
> Oct 17 21:10:08 saruman systemd: Can't open PID file
> /var/run/ndppd/ndppd.pid (yet?) after start: No such file or directory
>
> Examining the source, I see that the pidfile is created by the child
> process, not the parent. I'm guessing that systemd is expecting the pidfile
> to exist when the parent exits? (I want to file the issue on the upstream
> program and want to make sure I understand how this should work.)
>
> Source in question. Note how daemonize() forks and exits and main() invokes
> daemonize and then creates the pidfile. I'm thinking that daemonize()
> should create the pidfile before it invokes exit().
>
> 

the steps needed for this to work are clearly documented : man 7
daemon, section sysv daemons,
unfortunately I am yet to see any software in the wild doing this right..
but it doesn't matter. just..don't. execstart this program without -d
or -p switches, set the service Type= exec

Now.. you might consider networkd instead too.


Re: [systemd-devel] PIDFile creation logic

2021-10-18 Thread Silvio Knizek
Am Montag, dem 18.10.2021 um 12:43 -0700 schrieb Kenneth Porter:
> I just installed the new-to-EPEL ndppd service and am seeing this in my log:
>
> Oct 17 21:10:08 saruman systemd: Can't open PID file
> /var/run/ndppd/ndppd.pid (yet?) after start: No such file or directory
>
> Examining the source, I see that the pidfile is created by the child
> process, not the parent. I'm guessing that systemd is expecting the pidfile
> to exist when the parent exits? (I want to file the issue on the upstream
> program and want to make sure I understand how this should work.)
>
> Source in question. Note how daemonize() forks and exits and main() invokes
> daemonize and then creates the pidfile. I'm thinking that daemonize()
> should create the pidfile before it invokes exit().
>
> 
>
Hi,

just don't demonize and don't use a PIDFile= at all. systemd is
actually quite apt in figuring out which process is the right main one.
Also, the ndppd 0.2.5 release is 10 years old and doesn't look
maintained anymore.
OTOH, systemd-networkd itself has inbuilt NDPProxy capabilities.

BR
Silvio



[systemd-devel] PIDFile creation logic

2021-10-18 Thread Kenneth Porter

I just installed the new-to-EPEL ndppd service and am seeing this in my log:

Oct 17 21:10:08 saruman systemd: Can't open PID file 
/var/run/ndppd/ndppd.pid (yet?) after start: No such file or directory


Examining the source, I see that the pidfile is created by the child 
process, not the parent. I'm guessing that systemd is expecting the pidfile 
to exist when the parent exits? (I want to file the issue on the upstream 
program and want to make sure I understand how this should work.)


Source in question. Note how daemonize() forks and exits and main() invokes 
daemonize and then creates the pidfile. I'm thinking that daemonize() 
should create the pidfile before it invokes exit().