How can I make the same variable shared between the forked process? Or do I need to write to a file in the parent then read the value saved to the file in the child once the file exists? $something never appears to get set in this so it just loops in the sleep
my $something = -1;
&doit();
sub doit
{
my $pid = fork();
if ($pid == 0)
{
while ($something == -1)
{
print "sleep 1\n";
sleep 1;
}
&function2();
}
else
{
print "parent start\n";
sleep 2;
$something = 1;
print "parent end: $something\n";
}
}
sub function2 {
print "END\n";
}