Hello,
First I want to say thank you for this thread http://www.perlmonks.org/?node_id=470827. I tried the example of BrowserUk.
It is working with Linux and Windows. Then I added a cancel button which kills the external process. It is working in windows, but in my ubuntu linux the process is NOT killed. Why?
Here the code:
#!perl -slw use strict; use threads; use threads::shared; use Thread::Queue; ## A shared var to communicate progess between work thread and TK my $Q = new Thread::Queue; my $pid:shared; sub work{ $pid = open PROC, 'perl -le"$|=1; print and select(undef,undef,undef,0.1) for 1 .. 1 +000" |' or die $!; while( <PROC> ) { $Q->enqueue( $_ ); } close PROC; } threads->new( \&work )->detach; use Tk; use Tk::ProgressBar; my $mw = MainWindow->new; my $pb = $mw->ProgressBar()->pack(); my $repeat; $repeat = $mw->repeat( 100 => sub { while( $Q->pending ) { my $progress = $Q->dequeue; return unless $progress; $repeat->cancel if $progress == 100; $pb->value( $progress ) } } ); $mw->Button('-text' => 'Cancel', '-command' => sub{ kill 9, $pid })->pack(); $mw->MainLoop;
My question: Why is the killing of the external process with kill working in Windows and NOT working in Linux?
Thank you
Greetings,
Dirk
In reply to Tk and IPC - killing of process not working in Linux by Dirk80
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |