© 2023 PodTECH IO
All rights reserved.

Get in Touch

Perl

Perl – Basic Fork Example

#!/usr/local/bin/perl   use strict; use warnings;   print “Starting main program\n”; my @childs;   for ( my $count = 1; $count <= 10; $count++) {         my $pid = fork();         if ($pid) {         # parent         #print “pid is $pid, parent $$\n”;         push(@childs, $pid);         } elsif ($pid == 0) {                 # child                 sub1($count);                 exit 0;         } else […]

PHP

PHP – Basic Fork Example

<?   print “Starting main program\n”; $childs = array();   for ( $count = 1; $count <= 10; $count++) {         $pid = pcntl_fork();         if ( $pid == -1 ) {                 // Fork failed                           echo “Fork failed\n”;                 exit(1);         } else if ( $pid ) {                 # parent                 #print “pid is $pid, parent $$\n”;                 array_push($childs, $pid);         } […]