Hi, I'm new to perl/tk & also not an advance perl programmer,
I have read many posts that windows + fork + perl/tk doesn't go well.

Here's my problem, I have a program written in perl and I'm preparing a GUI for it.
I'm calling my existing program when I click a button on my GUI. I'm redirecting the STDOUT to a
scrolled text widget using this:

tie *STDOUT, 'Tk::Text', $widget;

my existing program prints to STDOUT at different intervals but the GUI freezes till my program returns,
as a result I'm forking a new process which will call my program, Here's the code:

sub startButton_Click { tie *STDOUT, 'Tk::Text', $widget; unless ($pid = fork) { &Automation::Automate($testCase_text, $testSpec_text, $config_text); # my program untie *STDOUT; exit 0; } } waitpid($pid, 0);

The above works just as expected except, that it throws an error and crashes,
just after the forked process finishes execution, this is the error:-

Attempt to free non-existent shared string '_TK_RESULT_' at C:/Perl/ site/lib/Tk. pm line 247. panic: restartop

I tried replacing the 'unless ($pid = fork)' block with an async{ } block (found this in some other forum),
but even then the same problem occurs with this error:-

Attempt to free non-existent shared string '_TK_RESULT_' at C:/Perl/ site/lib/Tk. pm line 247. thread failed to start: _TK_EXIT_(0) Free to wrong pool 233ee8 not 31df658 during global destruction.

Please help!! am I doing something wrong here or can I completely avoid forking a new process


In reply to Please suggest a non-forking way to do this (OS: windows) by cranky

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.