in reply to How do I close a pipe
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I close a pipe
by gmoque (Acolyte) on Dec 16, 2008 at 02:15 UTC |