Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 41a5a64337
Fetching contributors…

Cannot retrieve contributors at this time

file 23 lines (20 sloc) 0.597 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
use v6;
use NativeCall;

sub fork() returns Int is native() { ... }

my $children = 15;
for 1 .. $children -> $child {
    my $pid = fork();
    if $pid {
        print "created child $child process $pid. ";
        sleep 1; print "snore. ";
    }
    else {
        for $child .. $children { sleep 1; print "yawn $child. "; }
        exit 0;
    }
}

# Notes:
# * This code can hang your computer, depending on the number of
# children versus your real and virtual memory. For example, a 1GB
# netbook froze with 19 children.
# * Monitor your processes with a utility such as pstree or top.
Something went wrong with that request. Please try again.