hi everybody!I'm newbie.I have a exercise about perl like this:
Creating 2 process P1(parent) P2 (child)
P1 get characters from keyboard
If press Ctrl-c P1 send a signal terminate P2
......................................
My ideal is :
( perl )
$handle=IO::Socket::INET->(proto=>"tcp",
PeerAddr=>$host,
PeerPort=>$port)
$handle->autoflush(1);
die 'can't fork:$!' unless defined($pid=fork());
if($pid) {
while(defined($line=<$handle>)){
print STDOUT $line;
}
kill("TERM"=>$pid);
}
But my problem is press Ctrl-C.I think,can i creat a subroutine to respond to Ctrl-C like that:
$SIG{INT}=\&killchild;
sub killchild{
.............
}
Please help me