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

So, we have a parent process that has spawned a child process, which has in turn spawned a grandchild.

And the problem is that the grandparent doesn't even know the name of the grandchild. The child process doesn't call and it doesn't write. Nothing. (Is that not always the way ?)

Now, I'm not an expert on family counselling, but it seems to me that the problem here really is communication. I know that sounds like a cliche. But like many cliches, there's a kernel of truth hidden in it. See if you can somehow persuade the grandparent and child to talk to each other... then the joy of the grandchild can surely be shared.

I'm also not an expert on interprocess communication, so I'm guessing that my first thought -- email -- is probably too elaborate. Some form of pipe, perhaps ? perlipc

  • 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 accessdenied (Acolyte) on Nov 26, 2008 at 10:19 UTC
    I think about communication too. But there is no way to change behaviour of child. Actually I'm trying to fork DHCP daemon provided with SUSE10. Of course I can rewrite and recompile it but I have to support default binary and be able to provide my Perl script to any user of SUSE10 and it must work. Is there any way to handle starting/stopping of standard system daemons?
      Is there any way to handle starting/stopping of standard system daemons?
      On Debian that's simply /etc/init.d/daemonname start|stop, I'm sure that suse offers a similar way.

      A more low-level approach is to use start-stop-daemon directly.

        Yes, I know. I do exec() on daemon binary directly. But problem is that daemon binary inside itself have something like "fork() && exit()" which allow it to be a daemon. Side effect is that new PID is allocated to forked process.And PID saved in Perl script become useless trash. Is it clear enough?