in reply to Re: Re: Re: Re: Re: Re:(wog) Win32::Gui + Threading?
in thread Win32::Gui + Threading?

It still behaves the same with this code:
pipe(FROM_P, TO_C) or die "pipe: $!"; select(((select(TO_C), $| = 1))[0]); if (!(my $pid = fork)){ close(TO_C); my $running = 1; while(my $line = <FROM_P>) { #Win32::GUI::MessageBox(0,"Child Pid $$ just read this: $line"," +GMS Alert"); chomp($line) if($line =~ m/\n$/o); if(lc($line) eq 'exit'){ exit; } } }


So I don't think it's caused by the messagebox.


-----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

Replies are listed 'Best First'.
Re^8: (wog) Win32::Gui + Threading?
by wog (Curate) on Nov 13, 2001 at 05:39 UTC
    I think prehaps your behavior is caused by buffering of the input, then. Is the problem fixed when you close TO_P (after sending the exit command) or when you send exit\n instead of exit? (Which may be enough to convince perl that it should return from the <FROM_P> which I think it's not doing. But it'd be nice if you'd to have the forked process to print some stuff (to a file or STDERR) so you can tell where its hanging...)
      Oh... yep, that did it...

      Could I use something similar to that first pipe() command to get data back from the 2'nd process?

      Something like:
      pipe(FROM_C, TO_P) or die "pipe: $!"; select(((select(TO_P), $| = 1))[0]);


      ???


      -----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