I don't know the answer to this question. I do know that this fork() stuff in Windows doesn't work like in *NIX. The PID's under Windows are negative meaning that this is a thread emulation, not a really new PID. There is some code below.

When I write a Tk GUI with a long lived number cruncher app, I put up a Window with status and an "abort" button. This works because this is a single process and I call the thing managing the GUI progress bar often enough that the user won't notice any difference in performance if the user clicks on "stop". If you experiment with such an approach, you will find that updating the display is *very* expensive. On a 0-100% progress bar, you will find that you only want to update the display 100 times or maybe even only 50 times (once per 2%) (do a calculation and don't update the display more often than that). Looking about every 25 ms is way fast enough.

The way that you have described your app, it is started via a command line, not from the user "clicking a button" to start the "number cruncher". The Tk GUI creates lots of objects and then MainLoop() is called and the user then clicks on some button(s).

I think an equivalent question is: how to do I start a Tk GUI app and have my program punch one of the "go" buttons instead of the user having to do that?

#!/usr/bin/perl -w use strict; #this code is for WinXP, not Unix $| =1; #buffering is off! print "my Parent ID at start is: $$\n"; my $pid = fork(); if (!defined($pid)) { die "Couldn't fork"; } if ($pid == 0) #I am a child ## { print "My child PID =$$\n"; my $c =0; while ($c<10) { print $c++; sleep(1); } print "\n"; } else # I am parent ## { print "Parent PID = $$\n"; } print "end of PID = $$ process ID\n"; __END__ PRINTS: my Parent ID at start is: 3640 Parent PID = 3640 end of PID = 3640 process ID My child PID =-1628 0123456789 (one digit per second) end of PID = -1628 process ID

In reply to Re: killing a child process which contains a Tk Main window by Marshall
in thread killing a child process which contains a Tk Main window by vchristaras

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.