IPC-Run
view release on metacpan or search on metacpan
- Close $debug_fd in &sub coprocesses.
- Document the problems with &sub coprocesses.
- Fixed fork error return detection to actually work, spotted by Dave
Mitchell <davem@fdgroup.co.uk>.
- Give errors if a path with a directory separator is passed in if the
indicated filename does not exist, is not a file, or is not executable.
They're unixish errors, but hey...
- Allowed harness \@cmd, '>', $foo, timeout 10 ; to parse (it was mistakenly
thinking I wanted to send output to the IPC::Run::Timer created by
timeout().
- pumpable() now returns true if there are any kids left alive, so that
timers may continue to run.
- A timeout of 1 second is forced if there are no I/O pipes left open, so
that the select loop won't hang in select() if there is no I/O to do.
Perhaps should only do that if there are timers.
- Added a signal() to send specified signals to processes. Chose this over
the more traditional Unix kill() to avoid people thinking that kill()
should kill off processes.
- Added kill_kill() which does kill off processes and clean up the harness.
Sends TERM then (if need be) waits and sends KILL.
- timeouts now work.
lib/IPC/Run.pm view on Meta::CPAN
## dup2s on to these descriptors, since we unshift these. This way
## each process emits output to the same file descriptors that the
## last child will write to. This is probably not quite correct,
## since each child should write to the file descriptors inherited
## from the parent.
## TODO: fix the inheritance of output file descriptors.
## NOTE: This sharing of OPS among kids means that we can't easily put
## a kid number in each OPS structure to ping the kid when all ops
## have closed (when $self->{PIPES} has emptied). This means that we
## need to scan the KIDS whenever @{$self->{PIPES}} is empty to see
## if there any of them are still alive.
for ( my $num = 0; $num < $#{ $self->{KIDS} }; ++$num ) {
for ( reverse @output_fds_accum ) {
next unless defined $_;
_debug(
'kid ', $self->{KIDS}->[$num]->{NUM}, ' also to write ', $_->{KFD},
' to ', ref $_->{DEST}
) if _debugging_details;
unshift @{ $self->{KIDS}->[$num]->{OPS} }, $_;
}
}
lib/IPC/Run.pm view on Meta::CPAN
## Undocumented feature (don't depend on it outside this module):
## returns -1 if we have I/O channels open, or >0 if no I/O channels
## open, but we have kids running. This allows the select loop
## to poll for child exit.
sub pumpable {
my IPC::Run $self = shift;
## There's a catch-22 we can get in to if there is only one pipe left
## open to the child and it's paused (ie the SCALAR it's tied to
## is ''). It's paused, so we're not select()ing on it, so we don't
## check it to see if the child attached to it is alive and it stays
## in @{$self->{PIPES}} forever. So, if all pipes are paused, see if
## we can reap the child.
return -1 if grep !$_->{PAUSED}, @{ $self->{PIPES} };
## See if the child is dead.
$self->reap_nb;
return 0 unless $self->_running_kids;
## If we reap_nb and it's not dead yet, yield to it to see if it
## exits.
pty.t - Test suite for IPC::Run's pty (pseudo-terminal) support
=head1 DESCRIPTION
This test suite starts off with a test that seems to cause a deadlock
on freebsd: \@cmd, '<pty<', ... '>', ..., '2>'...
This seems to cause the child process entry in the process table to
hang around after the child exits. Both output pipes are closed, but
the PID is still valid so IPC::Run::finish() thinks it's still alive and
the whole shebang deadlocks waiting for the child to exit.
This is a very rare corner condition, so I'm not patching in a fix yet.
One fix might be to hack IPC::Run to close the master pty when all outputs
from the child are closed. That's a hack, not sure what to do about it.
This problem needs to be reproduced in a standalone script and investigated
further, but I have not the time.
=cut
( run in 0.977 second using v1.01-cache-2.11-cpan-39bf76dae61 )