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-deaecae0baffbf9b42a732aa7d707eb3e82b3c22.tar.gz posixruncapture-deaecae0baffbf9b42a732aa7d707eb3e82b3c22.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 @@ | |||
1 | Revision history for Perl extension POSIX::Run::Capture. | 1 | Revision history for Perl extension POSIX::Run::Capture. |
2 | 2 | ||
3 | 1.01 Fri Jan 31 09:16:30 2020 | ||
4 | - Argument to the 'stderr' or 'stdout' can be a code reference, | ||
5 | glob (file handle) or scalar string. In the latter two cases, | ||
6 | the stream is redirected to the file handle or the named file. | ||
7 | |||
3 | 1.00 Wed Aug 14 08:11:53 2019 | 8 | 1.00 Wed Aug 14 08:11:53 2019 |
4 | - line monitor is called for every line, whether or not terminated | 9 | - line monitor is called for every line, whether or not terminated |
5 | with a newline | 10 | with a newline |
@@ -153,7 +153,7 @@ capture_set_output(struct capture *cp, SV *cb[2], int strno) | |||
153 | } | 153 | } |
154 | } else { | 154 | } else { |
155 | char *filename = SvPV_nolen(sv); | 155 | char *filename = SvPV_nolen(sv); |
156 | int fd = open(filename, O_CREAT|O_TRUNC|O_RDWR, 0777); | 156 | int fd = open(filename, O_CREAT|O_TRUNC|O_RDWR, 0666); |
157 | if (fd == -1) { | 157 | if (fd == -1) { |
158 | croak("can't open file %s for writing: %s", | 158 | croak("can't open file %s for writing: %s", |
159 | filename, strerror(errno)); | 159 | 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'} } ); | |||
28 | 28 | ||
29 | #our @EXPORT = qw(); | 29 | #our @EXPORT = qw(); |
30 | 30 | ||
31 | our $VERSION = '1.00_01'; | 31 | our $VERSION = '1.01'; |
32 | 32 | ||
33 | require XSLoader; | 33 | require XSLoader; |
34 | XSLoader::load('POSIX::Run::Capture', $VERSION); | 34 | XSLoader::load('POSIX::Run::Capture', $VERSION); |
@@ -68,8 +68,8 @@ POSIX::Run::Capture - run command and capture its output | |||
68 | $obj = new POSIX::Run::Capture(argv => [ $command, @args ], | 68 | $obj = new POSIX::Run::Capture(argv => [ $command, @args ], |
69 | program => $prog, | 69 | program => $prog, |
70 | stdin => $fh_or_string, | 70 | stdin => $fh_or_string, |
71 | stdout => sub { ... }, | 71 | stdout => $ref_or_string, |
72 | stderr => sub { ... }, | 72 | stderr => $ref_or_string, |
73 | timeout => $n); | 73 | timeout => $n); |
74 | $obj->run; | 74 | $obj->run; |
75 | 75 | ||
@@ -94,7 +94,7 @@ POSIX::Run::Capture - run command and capture its output | |||
94 | 94 | ||
95 | Runs an external command and captures its output. Both standard error and | 95 | Runs an external command and captures its output. Both standard error and |
96 | output can be captured. Standard input can be supplied as either a | 96 | output can be captured. Standard input can be supplied as either a |
97 | filehandle or a text. Upon exit, the captured streams can be accessed line | 97 | filehandle or a string. Upon exit, the captured streams can be accessed line |
98 | by line or in one chunk. Callback routines can be supplied that will be | 98 | by line or in one chunk. Callback routines can be supplied that will be |
99 | called for each complete line of output read, providing a way for synchronous | 99 | called for each complete line of output read, providing a way for synchronous |
100 | processing. | 100 | processing. |
@@ -147,18 +147,20 @@ Notice that the last line read can lack the teminating newline character. | |||
147 | 147 | ||
148 | =item B<stdout> =E<gt> I<FH> | 148 | =item B<stdout> =E<gt> I<FH> |
149 | 149 | ||
150 | Capture standard output and write it to the file handle I<FH>. | 150 | Redirect standard output to file handle I<FH>. Obviously, the handle should |
151 | be writable. | ||
151 | 152 | ||
152 | =item B<stdout> =E<gt> I<NAME> | 153 | =item B<stdout> =E<gt> I<NAME> |
153 | 154 | ||
154 | Capture standard output and write it to the file I<NAME>. If the file | 155 | Capture standard output and write it to the file I<NAME>. If the file |
155 | exists, it will be truncated. | 156 | exists, it will be truncated. Otherwise, it will be created with permissions |
157 | of 0666 modified by the process' "umask" value. | ||
156 | 158 | ||
157 | =item B<stderr> =E<gt> I<$arg> | 159 | =item B<stderr> =E<gt> I<$arg> |
158 | 160 | ||
159 | Sets the I<line monitor> function for standard error or redirects it to | 161 | Sets the I<line monitor> function for standard error or redirects it to |
160 | the file handle or file, depending on the type of I<$arg>. See the | 162 | the file handle or file, depending on the type of I<$arg> (CODE reference, |
161 | description of B<stdout> above. | 163 | GLOB or scalar string). For details, see the description of B<stdout> above. |
162 | 164 | ||
163 | =item B<timeout> | 165 | =item B<timeout> |
164 | 166 | ||
@@ -182,7 +184,7 @@ Whatever constructor is used, the necessary parameters can be set | |||
182 | or changed later, using B<set_argv>, B<set_program>, B<set_input>, | 184 | or changed later, using B<set_argv>, B<set_program>, B<set_input>, |
183 | and B<set_timeout>. | 185 | and B<set_timeout>. |
184 | 186 | ||
185 | Monitors can be defined only when creating the object. | 187 | Monitors and redirections can be defined only when creating the object. |
186 | 188 | ||
187 | =head2 Modifying the object. | 189 | =head2 Modifying the object. |
188 | 190 | ||
@@ -293,7 +295,7 @@ Sergey Poznyakoff, E<lt>gray@gnu.orgE<gt> | |||
293 | 295 | ||
294 | =head1 COPYRIGHT AND LICENSE | 296 | =head1 COPYRIGHT AND LICENSE |
295 | 297 | ||
296 | Copyright (C) 2017 by Sergey Poznyakoff | 298 | Copyright (C) 2017-2020 by Sergey Poznyakoff |
297 | 299 | ||
298 | This library is free software; you can redistribute it and/or modify it | 300 | This library is free software; you can redistribute it and/or modify it |
299 | under the terms of the GNU General Public License as published by the | 301 | under the terms of the GNU General Public License as published by the |