> The following was supposedly scribed by
> Andy Adler
> on Sunday 29 February 2004 09:33 pm:

>    # doesn't die:
>    {
>       local $SIG{CHLD}  = \&reap;
>       open2( $Oout, $Oin, "/bin/sh" );
>    }
>    print $Oin "echo 'boo1' ; sleep 1; exit\n";
>    print while <$Oout>;

  {
   local $SIG{CHLD}  = \&reap;
   open2( $Oout, $Oin, "/bin/sh" );
  }
  print $Oin "echo 'boo1' ; sleep 2; exit\n";
  {
    local $SIG{CHLD} = \&reap;
    print while <$Oout>;
    close($Oin);
    # it dies ^-- here
    close($Oout);
  }

For some reason, the signal doesn't come until the input handle is closed.  
Presumably, you want to catch it if the child stops unexpectedly, so see if 
you can get it to work without the second block.

Note, that on my dual cpu system, this behaves differently sometimes.  I'm not 
quite sure where that comes from, but it seems that the print statement 
occassionally fires twice.

Maybe try it with IPC::Run ?

--Eric
-- 
Entia non sunt multiplicanda praeter necessitatem.
                                        --Occam's Razor

Reply via email to