Ok, I have fork working on win32. That's no problem. I downloaded the right version (5.6.0 bld 623) from activestate and fork works great. I even have it working with LWP so I can get a page in a child process and not interfere with the parent. The only problem is, when I try to exit the child, it wants to destroy something in the parent that is related to Tk. I do know that I want to use POSIX::exit(0) or just CORE::exit(0) but those have the same problem as just calling exit.

If I don't create a MainWindow, and just do a regular non gui perl script on windows, it works great to go get a web page in the background. See below. If you uncomment out the MainWindow creation line below though, it fails on the exit of the child and gives the error:

Attempt to free non-existent shared string at Widget.pm line 96 during global destruction

Here is the code:

#!/usr/local/bin/perl use POSIX; use POSIX ":sys_wait_h"; use Tk; use LWP::UserAgent; use URI::URL; my $ua = LWP::UserAgent->new; #my $mw = MainWindow->new(); if (!($pid = fork)) { $url = 'http://www.worldmusic.de/perl/dclpc-faq.html'; $file = 'web.txt'; my $req = HTTP::Request->new(GET => $url); $req->header('Accept' => 'text/html'); $res = $ua->request($req, $file); print "hi there, i'm a child about to exit\n"; POSIX::exit(0); } print "i'm the parent about to mainloop\n"; foreach $i (0..3) { sleep 4; print "i'm the parent about to mainloop\n"; } MainLoop;
Thanks for any help!!! Justin Eltoft

In reply to fork, tk, win32 by Eradicatore

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.