Skip to content

Instantly share code, notes, and snippets.

@khan5v
Created November 3, 2016 10:52
Show Gist options
  • Save khan5v/e65719ff299084edef9da346ba50790f to your computer and use it in GitHub Desktop.
Save khan5v/e65719ff299084edef9da346ba50790f to your computer and use it in GitHub Desktop.
Basic perl fork() example
use strict;
use warnings;
my $child_pid = fork();
if(defined $child_pid && $child_pid > 0) {
## Parent
wait();
print "p($$) c($child_pid) child finished, exiting\n";
} else {
## Child
foreach(1..60) {
print "p($$) c($child_pid) child is working\n";
sleep(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment