Sorry here is the correct code:
But now my parent process dies when i use:
exec('touch', $callCount);
die $!;
in child process. Here is the code:
while ($callCount <= $totalCalls) {
for (1..$callPerSec) {
printf "Call -> callCount";
my $pid = fork();
if($pid) {
#in Parent Process
printf " :: PID -> $pid\n";
push(@list_of_pid, $pid);
} elsif($pid == 0){
#in Child Process
exec ('touch', $callCount);
die $!;
} else {
printf "Resource Not available\n";
}
$callCount++;
}
print "Total Calls Executed $callCount\n";
|