The classic use of fork() is in client-server applications. The server just listens for new inbound connections and when one is detected, it accepts the connection to this new client and makes a "copy of itself" to handle whatever business this client wants. This "new copy" is known as a child process. The code is simplified as the server doesn't know how many "children" it has and each child deals with one client. Roughly speaking, this "start new copy of myself" is fork(). On Windows, this doesn't quite work this way and details get complicated, but same idea applies. There are a lot of "pesky details" to building good, robust client server applications.
One basic thing is: don't use system() or exec() if you can call a Perl module or function to do what you want. For example, you wouldn't want to call a shell command like 'ls' on Unix or 'dir' on Windows to list a directory.
Any way in programming fork is not a dining utensil, it is more like a "fork in the road".
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.