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