in reply to fork running parent and child parallel
Consider:
use strict; use warnings; use POSIX ":sys_wait_h"; my $pid = fork (); if ($pid == 0) { for (1 .. 10) { sleep 1; print 'c'; } } else { while (waitpid ($pid, WNOHANG) == 0) { print 'p'; sleep 1; } } print "\nDone\n";
Prints:
ppcpcpccpcpcpcpcpcpc Done p Done
|
|---|