in reply to Fork daemon from Perl script and save it's PID. How to do it right?

Many daemons save their pid in a file, check /var/run/dhcpd.pid.
  • Comment on Re: Fork daemon from Perl script and save it's PID. How to do it right?

Replies are listed 'Best First'.
Re^2: Fork daemon from Perl script and save it's PID. How to do it right?
by zwon (Abbot) on Nov 26, 2008 at 14:14 UTC

    Yeah, usually daemon is able to save its pid into file, also many of them allow to specify name of the pid file as comand line option, e.g inetd -p /var/run/inetd.pid. So you can create temporary file using File::Temp, fork and exec daemon with such option, so you can run multiple instances of daemon and each will use its own pid file.

    Another approach is to use option that prevents daemon from forking if it has one.