open(INPUTF, $ARGV[0]) || die("can't open filein:".$ARGV[0]);
pipe (INPUTP, OUTPUTP);
my $retval = fork();
if ($retval != 0) {
# this is the parent process
print "father print: my son is ".$retval."\n";
my $line = "";
close (OUTPUTP);
while(<INPUTP>)
{
$line = $_;
print "father print:".$line;
if($line =~ m/this\sis\sa\stest/g)
{
while(kill 0 => $retval)
{
print "father print: i should terminate my son:".$retval."\n";
kill (9, $retval);
}
}
}
} else {
# this is the child process