aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-07-21 13:25:07 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2017-07-21 13:33:04 +0300
commitec78df167efca7feba360b29700ef052eccf4b69 (patch)
tree1bcad85c0bc4696c0d87b45faefb9f00daef01cb /lib
parent9565c4d075158f27b5bfd6eab500f0e3f6d8c9ed (diff)
downloadposixruncapture-ec78df167efca7feba360b29700ef052eccf4b69.tar.gz
posixruncapture-ec78df167efca7feba360b29700ef052eccf4b69.tar.bz2
Improve constructor calling convention; implement timeout and line monitoring
* Capture.xs: Rewrite constructor to optionally take named arguments. * Makefile.PL: Remove 'subdirs-test_.*' rules. * capture.h (capture): New structure. All capture_ functions operate on it. * capture.c (capture_new): Change signature. Set line monitoring features if required. (capture_DESTROY): Free line buffers and dereference callback references. * lib/POSIX/Run/Capture.pm: Fix trivial error (get_lines): New method.
Diffstat (limited to 'lib')
-rw-r--r--lib/POSIX/Run/Capture.pm24
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/POSIX/Run/Capture.pm b/lib/POSIX/Run/Capture.pm
index 1d70d43..af28880 100644
--- a/lib/POSIX/Run/Capture.pm
+++ b/lib/POSIX/Run/Capture.pm
@@ -16,12 +16,12 @@ our @ISA = qw(Exporter);
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = ( 'all' => [ qw(
- STDOUT,
- STDERR
+ SD_STDOUT
+ SD_STDERR
) ],
'std' => [ qw(
- STDOUT,
- STDERR
+ SD_STDOUT
+ SD_STDERR
) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
@@ -34,11 +34,23 @@ require XSLoader;
XSLoader::load('POSIX::Run::Capture', $VERSION);
use constant {
- STDOUT => 1,
- STDERR => 2
+ SD_STDOUT => 1,
+ SD_STDERR => 2
};
# Preloaded methods go here.
+sub get_lines {
+ my ($self, $fd) = @_;
+ my @lines;
+
+ $self->rewind($fd);
+ while (my $s = $self->next_line($fd)) {
+ push @lines, $s;
+ }
+ return \@lines;
+}
+
+
1;
__END__

Return to:

Send suggestions and report system problems to the System administrator.