Goal: fork Linux daemon from Perl script, save it's PID and use PID to stop daemon later.
Daemon started by usual fork/exec pair.
Problem: in Perl script fork returns PID of new process. Then started daemon forks another one process, redirect input/output to /dev/null and become daemon itself. And of course PID changed because of internal fork in daemon.
So, result is - daemon is running but it's PID is different from saved in Perl script.
How to get right PID on fork of daemon?
I can't find it by myself, but I think that answer should exist. Perl and daemons are widely used, I don't believe that no one worked on this problem.