Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Parent process waiting for child process

by adpinc (Initiate)
on Oct 06, 2011 at 05:48 UTC ( #929941=perlquestion: print w/ replies, xml ) Need Help??
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
Re: Parent process waiting for child process
by Corion (Pope) 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://929941]
Approved by lidden
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2014-09-23 08:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (212 votes), past polls