The code is below. This is the code I'm working with to try and figure out how to get fork to work. But it is pretty much the same as my production code (same problem) except instead of going to sleep it does something that takes several minutes to run, and the window has more objects and looks nicer (but that isn't really important). You can change the value of the $howlong variable to decide how long it will sleep. Basically just click the button and then do things to the window or on the desktop. At the very least you will get a memory error when you exit the program. But sometimes you will also get it after the child process finishes. I found an example of a fork script that included several clean up (kill the child process when it was done, etc...). I used it to write a script that would just call one child process and then quit, it worked fine until it was added to a script that uses Win32::GUI. There must be one additional clean up process that needs to be done, I just don't know what it is.
The reason that I didn't cc to the mailing list is because the last two times I got an automated message from the admin of the mail list that read the email was a possible Spam letter and that it would not be sent. But it was sent anyway. I replied back asking why I got the message, but I haven't heard back from anyone. I'll cc the mail list, hopefully it was just a glitch. Start of code ===================================== use Win32::GUI; $howlong = 30; $MainWin = new Win32::GUI::Window( -name => "MainWin", -text => "Fork Test", -width => 500, -height => 350, -left => 100, -top => 100, -menu => $Menu, -font => $Font, ); $MainWin->AddButton( -name => "Button1", -text => "TEST", -align => center, -valign => center, -left => 350, -top => 10, ); $RTF = $MainWin->AddRichEdit( -name => "RTF", -left => 10, -top => 50, -width => $MainWin->ScaleWidth-20, -height => $MainWin->ScaleWidth-70, -multiline => 1, ); $MainWin->Show(); Win32::GUI::Dialog(); sub MainWin_Terminate { return -1; } sub Button1_Click { $MainWin->Button1->Disable(); my $pid = fork(); die "Fork failed: $!" if not defined $pid; if ($pid == 0) { do_stuff(); $MainWin->Button1->Enable(); exit; } } sub do_stuff { $RTF->ReplaceSel("Hello I am the child process and like any child I'm going to sleep while my parent keeps working.\r\n"); $RTF->ReplaceSel("So go ahead an minimize the window, move it, go to other windows and then back to this one.\r\n"); $RTF->ReplaceSel("My parent will do all the work.\r\n"); $MainWin->Update(); $MainWin->DoEvents(); sleep($howlong); $RTF->ReplaceSel("Finished sleeping\r\n"); } ============================= End of code