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":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.