Re: run an interactive command using POE::Wheel?

Olivier Mengué <[email protected]>
Newsgroups gmane.comp.lang.perl.poe
Message-ID <[email protected]>
> *POE::Kernel::USE_SIGCHLD = sub (){1};

If you want this line to be effective, you have to put it ABOVE the "use
POE" line.
And it is better written that way:
sub POE::Kernel::USE_SIGCHLD { 1 }
The way you wrote it would be less efficient as I expect the function would
not be inlined as a constant.


> Below is my code. If I input CTRL-C when the script asking for a username
or
> password, the script dose not exit even if I use $SIG{CHLD}='IGNORE'. By
'ps
> -ef', I can see that the get_name.pl is in the state of  "zombie" and
> waiting for the parent process to reap.

CTRL+C gives SIGBREAK, not SIGCHLD.
You are correctly handling SIGCHLD in on_child_signal, except, as Nick
pointed:
   $_[KERNEL]->sig_child($pid, 'got_child_signal');

You should add a SIGBREAK handler in on_start:
 $poe_kernel->sig(BREAK => 'on_sig_term');
 $poe_kernel->sig(TERM => 'on_sig_term');

sub on_sig_term
{
  if (exists $_[HEAP]->{job}) {
    $_[HEAP]->{job}->kill();
    delete $_[HEAP]->{job};
  }
  delete $_[HEAP]->{stdin};
  $poe_kernel->sig_handled();
}

Olivier.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.