Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^5: Fork Wait and probably grandchildren

by RazorbladeBidet (Friar)
on Apr 05, 2005 at 17:40 UTC ( [id://445056]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Fork Wait and probably grandchildren
in thread Fork Wait and probably grandchildren

Running
#!/usr/bin/perl -w use strict; for ( my $i = 0; $i < 11; $i++ ) { defined( my $pid = fork() ) or print STDERR "Unable to fork!"; if ( $pid ) { print "Child $i is $pid\n"; } else { print "Hi! I'm just a kid.. I'm going to sleep now..\n"; sleep rand(10); print "*Yawn* I'm awake! Huh? It's me! Kid $$! Bye bye! Time t +o die!\n"; exit 0; } } 1 while wait > 0; print "Screw this, I'm done waiting for those kids\n";
on AIX 5.2 gives
Child 0 is 876574 Hi! I'm just a kid.. I'm going to sleep now.. Child 1 is 1089612 Hi! I'm just a kid.. I'm going to sleep now.. Child 2 is 1216572 Hi! I'm just a kid.. I'm going to sleep now.. Child 3 is 913636 Hi! I'm just a kid.. I'm going to sleep now.. Child 4 is 1732802 Hi! I'm just a kid.. I'm going to sleep now.. Child 5 is 1470700 Hi! I'm just a kid.. I'm going to sleep now.. Child 6 is 2162768 Hi! I'm just a kid.. I'm going to sleep now.. Child 7 is 2555954 Hi! I'm just a kid.. I'm going to sleep now.. Child 8 is 2793494 Hi! I'm just a kid.. I'm going to sleep now.. Child 9 is 2863246 Hi! I'm just a kid.. I'm going to sleep now.. Child 10 is 3080302 Hi! I'm just a kid.. I'm going to sleep now.. *Yawn* I'm awake! Huh? It's me! Kid 1470700! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 2863246! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 2162768! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 876574! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 1089612! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 1732802! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 2555954! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 913636! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 1216572! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 2793494! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 3080302! Bye bye! Time to die! Screw this, I'm done waiting for those kids
changing that to just wait does
Child 0 is 2793496 Hi! I'm just a kid.. I'm going to sleep now.. Child 1 is 1077260 Hi! I'm just a kid.. I'm going to sleep now.. Child 2 is 1216574 Hi! I'm just a kid.. I'm going to sleep now.. Child 3 is 913638 Hi! I'm just a kid.. I'm going to sleep now.. Child 4 is 2555956 Hi! I'm just a kid.. I'm going to sleep now.. Child 5 is 1732804 Hi! I'm just a kid.. I'm going to sleep now.. Child 6 is 1089614 Hi! I'm just a kid.. I'm going to sleep now.. Child 7 is 876576 Hi! I'm just a kid.. I'm going to sleep now.. Child 8 is 2162770 Hi! I'm just a kid.. I'm going to sleep now.. Child 9 is 2863248 Hi! I'm just a kid.. I'm going to sleep now.. *Yawn* I'm awake! Huh? It's me! Kid 2863248! Bye bye! Time to die! Child 10 is 1470702 Hi! I'm just a kid.. I'm going to sleep now.. Screw this, I'm done waiting for those kids *Yawn* I'm awake! Huh? It's me! Kid 913638! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 1470702! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 2793496! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 1077260! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 876576! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 2162770! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 1216574! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 1089614! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 1732804! Bye bye! Time to die! *Yawn* I'm awake! Huh? It's me! Kid 2555956! Bye bye! Time to die!
--------------
"But what of all those sweet words you spoke in private?"
"Oh that's just what we call pillow talk, baby, that's all."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://445056]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-29 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found