in reply to Re^2: Perl non-blocking IPC
in thread Perl non-blocking IPC
$fh = FileHandle->new("tail -f -n 25 command_file |");
The only way to get the $pid is to use a piped-open as described in perldoc perlipc, or use something like IPC::Open3, but you sometimes get a shell pid, which then executes your program.
So use something like this:
Before I get slapped on the wrist for using killfam 9, remember that 9 is an instant kill, you may want to use a softer signal like 15, to allow the program to gracefully close.my $fh = new FileHandle; my $pid = open( $fh , "tail -f -n 25 command_file | ") or die ; #..... # now you can check the output of ps to see if you get a shell $pid # or just your process $pid # then to make sure you kill all shells and commands, if you see # the $pid is the shell use Proc::Killfam; $mw->protocol('WM_DELETE_WINDOW' => sub { killfam 9,$pid; exit; }); # or put the killfam in the callback of an Exit button, etc
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Perl non-blocking IPC
by brian42miller (Sexton) on Jul 07, 2011 at 16:26 UTC |