diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2020-01-31 11:20:06 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2020-01-31 11:20:06 +0200 |
commit | deaecae0baffbf9b42a732aa7d707eb3e82b3c22 (patch) | |
tree | 4b79569bf4769c249e42db32fc7d96f2758b89f3 | |
parent | 1e656052f14c3adc0646cb15cfd88ec30c0eb794 (diff) | |
download | posixruncapture-1.01.tar.gz posixruncapture-1.01.tar.bz2 |
Fix mode of the created output file.v1.01
* Changes: Document changes.
* capture.c (capture_set_output): Fix mode of the created file.
* lib/POSIX/Run/Capture.pm: Improve documentation. Set version
number 1.01.
-rw-r--r-- | Changes | 5 | ||||
-rw-r--r-- | capture.c | 2 | ||||
-rw-r--r-- | lib/POSIX/Run/Capture.pm | 22 |
3 files changed, 18 insertions, 11 deletions
@@ -1,5 +1,10 @@ Revision history for Perl extension POSIX::Run::Capture. +1.01 Fri Jan 31 09:16:30 2020 + - Argument to the 'stderr' or 'stdout' can be a code reference, + glob (file handle) or scalar string. In the latter two cases, + the stream is redirected to the file handle or the named file. + 1.00 Wed Aug 14 08:11:53 2019 - line monitor is called for every line, whether or not terminated with a newline @@ -153,7 +153,7 @@ capture_set_output(struct capture *cp, SV *cb[2], int strno) } } else { char *filename = SvPV_nolen(sv); - int fd = open(filename, O_CREAT|O_TRUNC|O_RDWR, 0777); + int fd = open(filename, O_CREAT|O_TRUNC|O_RDWR, 0666); if (fd == -1) { croak("can't open file %s for writing: %s", filename, strerror(errno)); diff --git a/lib/POSIX/Run/Capture.pm b/lib/POSIX/Run/Capture.pm index 57c7d57..35275c1 100644 --- a/lib/POSIX/Run/Capture.pm +++ b/lib/POSIX/Run/Capture.pm @@ -28,7 +28,7 @@ our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); #our @EXPORT = qw(); -our $VERSION = '1.00_01'; +our $VERSION = '1.01'; require XSLoader; XSLoader::load('POSIX::Run::Capture', $VERSION); @@ -68,8 +68,8 @@ POSIX::Run::Capture - run command and capture its output $obj = new POSIX::Run::Capture(argv => [ $command, @args ], program => $prog, stdin => $fh_or_string, - stdout => sub { ... }, - stderr => sub { ... }, + stdout => $ref_or_string, + stderr => $ref_or_string, timeout => $n); $obj->run; @@ -94,7 +94,7 @@ POSIX::Run::Capture - run command and capture its output Runs an external command and captures its output. Both standard error and output can be captured. Standard input can be supplied as either a -filehandle or a text. Upon exit, the captured streams can be accessed line +filehandle or a string. Upon exit, the captured streams can be accessed line by line or in one chunk. Callback routines can be supplied that will be called for each complete line of output read, providing a way for synchronous processing. @@ -147,18 +147,20 @@ Notice that the last line read can lack the teminating newline character. =item B<stdout> =E<gt> I<FH> -Capture standard output and write it to the file handle I<FH>. +Redirect standard output to file handle I<FH>. Obviously, the handle should +be writable. =item B<stdout> =E<gt> I<NAME> Capture standard output and write it to the file I<NAME>. If the file -exists, it will be truncated. +exists, it will be truncated. Otherwise, it will be created with permissions +of 0666 modified by the process' "umask" value. =item B<stderr> =E<gt> I<$arg> Sets the I<line monitor> function for standard error or redirects it to -the file handle or file, depending on the type of I<$arg>. See the -description of B<stdout> above. +the file handle or file, depending on the type of I<$arg> (CODE reference, +GLOB or scalar string). For details, see the description of B<stdout> above. =item B<timeout> @@ -182,7 +184,7 @@ Whatever constructor is used, the necessary parameters can be set or changed later, using B<set_argv>, B<set_program>, B<set_input>, and B<set_timeout>. -Monitors can be defined only when creating the object. +Monitors and redirections can be defined only when creating the object. =head2 Modifying the object. @@ -293,7 +295,7 @@ Sergey Poznyakoff, E<lt>gray@gnu.orgE<gt> =head1 COPYRIGHT AND LICENSE -Copyright (C) 2017 by Sergey Poznyakoff +Copyright (C) 2017-2020 by Sergey Poznyakoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the |