I've been playing around with
fork for the last couple of days and I think I have a pretty good grasp of how a "plain" fork works. It creates a copy of the script and executes the copy. Thats all well, good and simple, but how does that extend to situations like so:
while(my $client = $server->accept())
{
next if fork;
# random
# client
# handling
# stuff
exit;
}
Obviously I know it works and does what it's supposed to do, but how does the fork work in context of the while loops? It seems like its trying to
goto the middle of a while loop, which I thought was impossible. Can anyone help me out here?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.