Dear Monks,
In the below code,the $extflag i am setting to 1 inside parent process,but in the child process the same flag is still available as 0 and the while loop is getting executed infinite loop,So even the $extflag is a global variable it is acting like a local variable.
Can Anyone please let me know how can i avoid the while loop getting executed infiniteThe code is given below.
$extflag=0;
print"Flag outside loop=> $extflag\n";
if(defined($pid = fork)) {
if ( $pid ) {
print"PARENT PROCESS\n";
$extflag=1;
print"Flag inside paretn=> $extflag\n";
waitpid ($pid,0);
}
else {
print"CHILD PROCESS\n";
sleep 10;
while(!$extflag){
print"Flag inside while child > $extflag\n";
}
print"Flag outide while in cheild=> $extflag\n";
}
}
Regards,
madtoperl