Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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 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 (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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://929941]
Approved by lidden
[Discipulus]: me waterpolo? oh no! i'm a no sport; the tournment was for the elder son
[karlgoethebier]: good morning
[Corion]: Discipulus: Ah, so he's the one getting almost drowned all the time - waterpolo certainly is no sport for me ;)
[karlgoethebier]: Corion: buy enough coke and popcorn...
[marto]: Corion the cinema is a lot more expensive than I remember :P
Discipulus hates the smell of popcorn at cinemas..
[Corion]: marto: Yeah, most of the time, I prefer to watch stuff at home, where we can sit on the couch, order pizza and pause the movie. But for kids,...
[Corion]: ... I think the "cinema experience" is something of its own. But certainly, bringing an USB stick home is much easier ;-D

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (11)
As of 2017-07-24 08:18 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (348 votes). Check out past polls.