in reply to Re: •Re: Catching signals
in thread Catching signals

Ahh. That code works as expected for me. The signal handler is called in both the parent and the child. I had to use a ^Z to finally get out of the code.

So, what's your perl -V look like?

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: •Re: Re: •Re: Catching signals
by gri6507 (Deacon) on Sep 04, 2002 at 18:41 UTC
    Please see 195144 for my answer and RMGir's reply. Is there any other work around to communicate between child and parent under win32? (this all started when a child was doing a blocking read and the parent was used to break out of that read cycle) So far, I have tried pipe $parent,$child or die, which still seemed to be blocked by that read statement. I also tried open(TO,"$-") || die but that's not supported by win32 either. I also tried threads, but activestate, in a stroke of genius, did not compile the perl.exe binary with 5005Threads, which makes the Thread.pm module useless. Instead, they compiled it with iThreads, which, even after getting threads.pm and threads::shared.pm into perl 5.6.1, do not seem to work for me (I get an error message saying that perl version is less than 5.8).

    Any other suggestions?

      Hi,

      I realize that this is not necessarily the answer to the question I was orignially asking, but it certainly is a solution to my problem (see the parent node). The problem was that I could not have a responsive Tk GUI running in parallel with a blocking socket read (Tk::fileevent under Win32 is broken - at least on perl 5.6.1 - I think it should be fixed by 5.7 or 5.8). Well, FYI, here's a hack that works.

      use IO::Socket; use IO::Select; use Tk; use strict; my $mw = MainWindow->new; my $text = $mw->Text->pack(); my $button = $mw->Button(-text=>"quit",-command=>sub{exit;})->pack; my $sock = IO::Socket::INET->new( Listen => 5, Reuse => 1, LocalPort => 7076, Proto => 'tcp', ) or die "Couldn't open socket: $!"; my $sel = IO::Select->new; $sel->add($sock); $mw->repeat(50 => \&read_sock); MainLoop; sub read_sock { my(@ready) = $sel->can_read(0); return if $#ready == -1; my $line; my $new_sock = $sock->accept(); $line = <$new_sock>; $text->insert('end',"$line\n"); }