App-nrun
view release on metacpan or search on metacpan
if (not $$_options->{ppid} eq $$) {
exit();
}
while (waitpid(-1, WNOHANG) != -1) { };
}
###
# initialize the sink object
sub sink_init() {
my $_self = shift;
my @filters;
foreach my $logger (@{$options->{logger}}) {
my $l = NRun::Logger::loggers()->{$logger}->{NAME}->new();
$l->init($options);
push(@filters, $l);
if (not $$_options->{ppid} eq $$) {
exit();
}
while (waitpid(-1, WNOHANG) != -1) { };
}
###
# initialize the sink object
sub sink_init() {
my $_self = shift;
my @filters;
foreach my $logger (@{$options->{logger}}) {
my $l = NRun::Logger::loggers()->{$logger}->{NAME}->new();
$l->init($options);
push(@filters, $l);
lib/NRun/Queue.pm view on Meta::CPAN
$_self->{pipes} = [];
}
###
# connect the currently running process to this queue.
#
# - must be called once before each fork()
# - must be called before start() and next()
# - must be called in the parent's context
sub connect() {
my $_self = shift;
my ( $child, $parent );
socketpair($child, $parent, AF_UNIX, SOCK_STREAM, PF_UNSPEC) or die "socketpair: $!";
$child->autoflush(1);
$parent->autoflush(1);
lib/NRun/Sink.pm view on Meta::CPAN
$_self->{RDR1} = [];
$_self->{RDR2} = [];
}
###
# connect the currently running process to this sink.
#
# - must be called once before each fork()
# - must be called before process(), open() and close()
# - must be called in the parent's context
sub connect() {
my $_self = shift;
my ( $rdr1, $rdr2 );
pipe($rdr1, $_self->{WRT1});
pipe($rdr2, $_self->{WRT2});
push(@{$_self->{RDR1}}, $rdr1);
push(@{$_self->{RDR2}}, $rdr2);
lib/NRun/Sink.pm view on Meta::CPAN
}
}
}
}
###
# connect STDOUT and STDERR from the current process to
# this sink.
#
# - must be called in the child's context
sub open() {
my $_self = shift;
return if (defined($_self->{OLDOUT}));
foreach my $RDR1 (@{$_self->{RDR1}}) {
close($RDR1);
}
lib/NRun/Sink.pm view on Meta::CPAN
open(STDOUT, ">&" . fileno($_self->{WRT1})) or die ("unable to redirect stdout: $!");
open(STDERR, ">&" . fileno($_self->{WRT2})) or die ("unable to redirect stderr: $!");
}
###
# disconnect STDOUT and STDERR from the current process to
# this sink.
#
# - must be called in the child's context
sub close() {
my $_self = shift;
return if (not defined($_self->{OLDOUT}));
CORE::open(STDOUT, ">&" . fileno($_self->{OLDOUT})) or die ("unable to restore stdout: $!");
CORE::open(STDERR, ">&" . fileno($_self->{OLDERR})) or die ("unable to restore stderr: $!");
delete($_self->{OLDOUT});
delete($_self->{OLDERR});
( run in 0.753 second using v1.01-cache-2.11-cpan-65fba6d93b7 )