open(INPUTF, $ARGV[0]) || die("can't open filein:".$ARGV[0]); $retval = open(FROMCHILD, "-|"); if ($retval) { # this is the parent process
print "father print: my son is ".$retval."\n"; $line = ""; close(STDIN); while(<FROMCHILD>) { $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
while(<INPUTF>) { print $_; sleep(1); } exit; }
|