owl1 has asked for the wisdom of the Perl Monks concerning the following question:

  • hi All
  • Is it possible to create independent processes with the use of "Proc::Daemon::Init()" from a single script and have them communicate with each other

    for($i;$i<2;$i++) { # This would spwan four independent $pid= fork; # processes Proc::Daemon::Init(); }
  • i am not sure how i could store their pids
  • And get all of them to talk to one another
  • Any help would be appreciated

  • THANKS
  • Replies are listed 'Best First'.
    Re: Process as daemon, communicate back
    by naChoZ (Curate) on Dec 21, 2007 at 15:23 UTC

      Daemonizing your scripts doesn't really have anything to do with inter process communication. I know some folks use network sockets for communication between perl programs and there's some discussion over in the Q&A section under network programming section and a little bit under the programs and processes section. You could also search around the IPC modules on CPAN.

      Hope that helps. I'm not experienced in these matters personally, just some observations.

      --
      naChoZ

      Therapy is expensive. Popping bubble wrap is cheap. You choose.

    Re: Process as daemon, communicate back
    by HeatSeekerCannibal (Beadle) on Dec 21, 2007 at 16:16 UTC
      I havent used that module, but if you're in *nix, you could use fork without much problem.

      As for the InterProcess Communication (IPC) perlipc part, there are a number of options.

      I'm partial towards Shared Memory, but it would involve semaphores. From my point of view its the most powerful solution, but consider if your problem merits the extra work (synchronization).

      If you need sample code for forking child processes or shared memory, let me know. I must have some stored somewhere.

      Heatseeker Cannibal

        Thanks Cannibal

        Sample code involving independent process accessing the same data with the use of "IPC::Shareable" would be helpful

        Also, the processes are all on the same machine

      • Thanks