Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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."

In reply to Re^5: Fork Wait and probably grandchildren by RazorbladeBidet
in thread Fork Wait and probably grandchildren by Discordanian

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found