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


In reply to Re: Re: Fork Information by hackmare
in thread Fork Information by blacksmith

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.