http://qs321.pair.com?node_id=88567


in reply to Fork Information

Maybe not as thorough as you'd like, but I think the first place you should lok (if you haven't already) is the perl docs for fork. It also links to perlipc which also has some good related information.

Replies are listed 'Best First'.
Re: Re: Fork Information
by hackmare (Pilgrim) on Jun 15, 2001 at 13:37 UTC

    koolade:

    I often find the explanations for fork to be usually a little self-imporant (as they were for me when I got started).

    Here's teh babble-free version of fork as it was originally explained to me

    Your program runs instructions sequentially, like a car driving by itself down the road, where each traffic event (stop light, intersection, traffic sigh) is the equivalent of a code instruction (such as print "hello,world.\n") in the source code.

    When you fork, you are cloning your car and giving the clone its own identity, and telling each car about the existance of the other car.

    What happens now is that each car starts going down the same road (the same code, starting from the fork command) in parallel, at first, until the second car finds an instruction telling it to do something based on its identity as the second car (the child)

    And this goes on until something tells one of the cars (the parent or the child) to dissapear.

    Now, something to consider is that this second car takes a lot of energy to generate (and a fork ahs a fair bit of overhead at first).

    I hope you dont find this explanation too pedantic.
    For a real explanation, refer to the doc as advised by the others.

    --Hackmare

      Not pedantic at all (unless you meant the good connotation of pedantic) I finally understand what fork is all about.