if (fork() == 0) { system("sh", "-c", "sleep 3 # getting yandex translation"); exit(0); } if (fork() == 0) { system("sh", "-c", "sleep 2; # getting google translation"); exit(0); } system("pstree -Apal $$"); # pstree gets the PID of the parent process as its argument while((my $pid = wait()) != -1) { say "$pid terminated" } __END__ perl,29173 test.pl |-perl,29174 test.pl | `-sh,29177 -c sleep 3 # getting yandex translation | `-sleep,29179 3 |-perl,29175 test.pl | `-sh,29178 -c sleep 2; # getting google translation `-pstree,29176 -Apal 29173 29175 terminated 29174 terminated #### my $start = time; if (fork() == 0) { # arm the alarm clock alarm(10); # create a child process that sleeps system("sleep 365d"); exit(0); } system("pstree -Apal $$"); while((my $pid = wait()) != -1) { say "$pid terminated" } say time-$start, " seconds elapsed instead of a year" __END__ perl,29620 |-perl,29621 | `-sleep,29623 365d `-pstree,29622 -Apal 29620 29621 terminated 10 seconds elapsed instead of a year