I downloaded your script and ran it under the perl debugger on my linux box. As described the Cancel button did not kill the process.

I set a breakpoint on sub work(), and made a note of $pid, and the pid of the perl process.

DB<1> b work DB<2> c main::work(test.pl:12): $pid = open PROC, main::work(test.pl:13): 'perl -le"$|=1; print and select(undef,und +ef,undef,0.1) for 1 .. 1000" |' main::work(test.pl:14): or die $!; DB<2> n DB<2> x $pid 0 9940 DB<3> x $$ 0 9850

From there, I ran pstree in a normal bash shell to check the child processes of the perl script:

/tmp$ pstree -apA 9850 perl,9850 -d -I /etc/perl -I /usr/local/lib/perl/5.10.1 -I /usr/local/ +share/perl/5.10.1 -I |-sh,9940 -c perl -le"$|=1; print and select(undef,undef,undef,0.1) +for 1 .. 1000" | `-perl,9941 -le$|=1; print and select(undef,undef,undef,0.1) for + 1 .. 1000 `-{perl},9939

What this basically means, is that when you stated the test process, you actually started a shell which started the test process. It was the process ID of that shell that you had stored in $pid. When you sent a kill signal to that PID your killed the shell, but not it's child process.

I think you need to figure out how to start your process without going via a shell. I know you can do it via a fork/exec but that is probably to heavyweight and not portable to windows. There are probably other ways, but I don't know them off the top of my head. I suggest you read perlipc.


In reply to Re: Tk and IPC - killing of process not working in Linux by chrestomanci
in thread Tk and IPC - killing of process not working in Linux by Dirk80

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.