What happend with parent proces.
Two scripts:
perl4:
[CODE=perl]#
# loop operations
#
use strict;
my @food;
my $morsel;
my $TableLength;
my $i;
@food = ("pear", "plum", "egg", "apple");
#
# Table printing
#
$TableLength = $#food;
print $TableLength;
foreach $i (@food){
print $i."\n";
}
do
{
print "Password?" ;
$a = <STDIN>;
chop $a;
}
while ($a ne "fred");[/CODE]
perl5:
[CODE=perl]# Variable declaration
my $FileName = "perl4.pl";
my $Line = "";
my @Table;
my $pid;
$pid = system $FileName;
if(not defined $pid){
#child
print "no resources";
}elsif($pid == 0)
{
print "I am a child";
STDOUT->autoflush();
sleep(5);
print "I am a child2\n";
}else{
print "I am a parent";
STDOUT->autoflush();
}[/CODE]
printout:
prear
plum
egg
apple
Password?fred
I am a childI am a child2
And I have no output from parent process. Can anybody explain me why?
Two scripts:
perl4:
[CODE=perl]#
# loop operations
#
use strict;
my @food;
my $morsel;
my $TableLength;
my $i;
@food = ("pear", "plum", "egg", "apple");
#
# Table printing
#
$TableLength = $#food;
print $TableLength;
foreach $i (@food){
print $i."\n";
}
do
{
print "Password?" ;
$a = <STDIN>;
chop $a;
}
while ($a ne "fred");[/CODE]
perl5:
[CODE=perl]# Variable declaration
my $FileName = "perl4.pl";
my $Line = "";
my @Table;
my $pid;
$pid = system $FileName;
if(not defined $pid){
#child
print "no resources";
}elsif($pid == 0)
{
print "I am a child";
STDOUT->autoflush();
sleep(5);
print "I am a child2\n";
}else{
print "I am a parent";
STDOUT->autoflush();
}[/CODE]
printout:
prear
plum
egg
apple
Password?fred
I am a childI am a child2
And I have no output from parent process. Can anybody explain me why?
Comment