http://www.perlmonks.org?node_id=929941

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

Hello there! I'm a long time Perl writer. I've been writing Perl scripts for years. This is the first time I've ever hit a roadblock that a simple google search or flip through one of my books didn't help. I've written many webpages with CGI.pm. Works great. I have come across a need to spawn a background process and want the parent to continue after launching the code. I've tried embedding the '&' in a system call. I've tried leading with a "1" and a "nohup." I've tried Proc::Background and Proc::Simple. I've tried various fork() code snippets. I've tried setting $|=1. No matter what happens, when my webpage code hits the line to spawn the background process, the webpage waits until the child process completes before continuing. The background process works fine. I just cannot seem to get the Parent process calling the child to simply move on to the next line of code. I am on a Linux platform running Perl 5.008008. Any help would be greatly appreciated. Thank you! adpinc
  • Comment on Parent process waiting for child process

Replies are listed 'Best First'.
Re: Parent process waiting for child process
by Corion (Patriarch) on Oct 06, 2011 at 07:01 UTC
      I think the step most people overlook, is that when you use fork, then child process has to 'close STDOUT', in order to "break the connection" to the web server.