Dirk80 has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk and IPC - killing of process not working in Linux
by chrestomanci (Priest) on Feb 12, 2011 at 22:15 UTC | |
by Dirk80 (Pilgrim) on Feb 13, 2011 at 15:53 UTC | |
by Dirk80 (Pilgrim) on Feb 22, 2011 at 19:42 UTC | |
|
Re: Tk and IPC - killing of process not working in Linux
by BrowserUk (Patriarch) on Feb 12, 2011 at 20:55 UTC | |
by Dirk80 (Pilgrim) on Feb 12, 2011 at 21:30 UTC | |
by BrowserUk (Patriarch) on Feb 12, 2011 at 21:46 UTC | |
|
Re: Tk and IPC - killing of process not working in Linux
by Khen1950fx (Canon) on Feb 13, 2011 at 05:31 UTC | |
|
Re: Tk and IPC - killing of process not working in Linux
by ww (Archbishop) on Feb 12, 2011 at 20:50 UTC |