The piped open returns the pid of the child process. So just kill it once you're done with it:
#!/usr/bin/perl $SIG{INT} = \&end; my $kid = open (TELNET, '-|', "telnet 192.168.1.1 6088"); while(<TELNET>) { $arr = <TELNET>; $arr =~ s/[\r\n](.....):(.*)/<p class="$1">$1:$2<\/p>/; print $arr; } end; sub end { print "Closing the session ...\n" # close FH; close TELNET; kill 2, $kid; ## Or whatever signal is appropriate! print "Session closed!\n" exit; }
In reply to Re: How do I close a pipe
by BrowserUk
in thread How do I close a pipe
by gmoque
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |