I've tried this (based upon several examples... I really still don't understand what most of this is doing...):
pipe(FROM_P, TO_C) or die "pipe: $!";
select(((select(TO_C), $| = 1))[0]);
if (!(my $pid = fork)){
close(TO_C);
#close(FROM_C);
my $running = 1;
while(my $line = <FROM_P>) {
Win32::GUI::MessageBox(0,"Child Pid $$ just read this: $line","G
+MS Alert");
chomp($line) if($line =~ m/\n$/o);
if(lc($line) eq 'exit'){
Win32::GUI::MessageBox(0,"Exit","GMS");
sleep(20); #To allow time to read the MessageBox... if it eve
+r comes up...
exit;
}
}
}
Later on, these two subs deal with the exiting of the main program:
sub GMSMain_Terminate
{
defined(my $win = $Win32::GUI::Loft::window{GMSMain}) or return(1);
print TO_C 'exit';
return(-1);
}
sub mnuFileExit_Click
{
defined(my $win = $Win32::GUI::Loft::window{GMSMain}) or return(1);
print TO_C 'exit';
return(-1);
}
When running it, however, I can exit part of it (the gui part) but it remains visible and perl itself keeps running. There is no message box popping up from the other process either.
I'm probably making a rather stupid mistake, so please point it out if I am.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GIT d- s:++ a--- C++++ UL P+++>++++ L+ E- W++>+++ N !o K- w+ O---- M-- V--
PS PE Y- PGP t++(+++) 5(+++)++++ X R+@ tv+ b+++ DI+ D- G e->+++ h! r-- y-
------END GEEK CODE BLOCK------
Translate
"Weird things happen, get used to it."
Flame ~ Lead Programmer: GMS
|