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

To Fork or not to Fork

by Shacalla (Initiate)
on Jun 04, 2002 at 22:44 UTC ( [id://171664]=perlquestion: print w/replies, xml ) Need Help??

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

I am writing a piece of code that has basically two parts, the first waits for an event on the system at which point it calls another piece of code to do something totally different. As of now I have written them as two seperate scripts, with the first just calling the second outright (as the command line would call it). My question is this, is this the best/most useful way to do this or should I try to combine the two smaller scripts into one? Any suggestions?

Replies are listed 'Best First'.
Re: To Fork or not to Fork
by crazyinsomniac (Prior) on Jun 04, 2002 at 22:49 UTC
      Yeah, sorry about scimping on the details, truthfully I just wasn't sure what to include. To answer your question basically all the communication is just passing arguments and flags which occur once at the beginning of the second script, but after that, as far as I can tell as of now, no communcation is needed.
Re: To Fork or not to Fork
by Abigail-II (Bishop) on Jun 05, 2002 at 15:43 UTC
    It depends. Do you want to wait for the first to finish before spawning a second? Then you could use system. Do you just want to spawn and forget? Ignore SIGCHLD, and use fork and exec. Do you want at most one child active at all times, which isn't allowed to live for ever? Then you would use fork and exec, and you'd set up handlers for SIGCHLD and SIGALRM.

    Abigail

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-19 10:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found