Simple fork examples

M

Michele Dondi

Hello All,

THis fork example is too good . can somebody explain me how this
works???....



"it_says_BALLS_on_your forehead" <[email protected]> wrote in message

*PLEASE* do not top post!

Well, just do something $num_kids times: the corresponding index, $i,
will be the "name" of the process.

Call fork().

If it is undef() then it didn't succeed at all. The die() immediately
with an error message. (But on a second thought, what if previous
fork()s succeeded?)

I am the child process.

So I say something, wait three seconds, say something else to make it
clear that it's me, and then I go away.

Since childs exit() early, this portion of code is only reached if I
am the parent. And I say so, mentioning my child.

Wait for all the childs to exit, to avoid leaving zombies laying
around.


Michele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top