aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2020-01-31 11:20:06 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2020-01-31 11:20:06 +0200
commitdeaecae0baffbf9b42a732aa7d707eb3e82b3c22 (patch)
tree4b79569bf4769c249e42db32fc7d96f2758b89f3
parent1e656052f14c3adc0646cb15cfd88ec30c0eb794 (diff)
downloadposixruncapture-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--Changes5
-rw-r--r--capture.c2
-rw-r--r--lib/POSIX/Run/Capture.pm22
3 files changed, 18 insertions, 11 deletions
diff --git a/Changes b/Changes
index 7238169..d14733e 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,10 @@
1Revision history for Perl extension POSIX::Run::Capture. 1Revision history for Perl extension POSIX::Run::Capture.
2 2
31.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
31.00 Wed Aug 14 08:11:53 2019 81.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
diff --git a/capture.c b/capture.c
index d5828ea..a925692 100644
--- a/capture.c
+++ b/capture.c
@@ -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
31our $VERSION = '1.00_01'; 31our $VERSION = '1.01';
32 32
33require XSLoader; 33require XSLoader;
34XSLoader::load('POSIX::Run::Capture', $VERSION); 34XSLoader::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
95Runs an external command and captures its output. Both standard error and 95Runs an external command and captures its output. Both standard error and
96output can be captured. Standard input can be supplied as either a 96output can be captured. Standard input can be supplied as either a
97filehandle or a text. Upon exit, the captured streams can be accessed line 97filehandle or a string. Upon exit, the captured streams can be accessed line
98by line or in one chunk. Callback routines can be supplied that will be 98by line or in one chunk. Callback routines can be supplied that will be
99called for each complete line of output read, providing a way for synchronous 99called for each complete line of output read, providing a way for synchronous
100processing. 100processing.
@@ -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
150Capture standard output and write it to the file handle I<FH>. 150Redirect standard output to file handle I<FH>. Obviously, the handle should
151be writable.
151 152
152=item B<stdout> =E<gt> I<NAME> 153=item B<stdout> =E<gt> I<NAME>
153 154
154Capture standard output and write it to the file I<NAME>. If the file 155Capture standard output and write it to the file I<NAME>. If the file
155exists, it will be truncated. 156exists, it will be truncated. Otherwise, it will be created with permissions
157of 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
159Sets the I<line monitor> function for standard error or redirects it to 161Sets the I<line monitor> function for standard error or redirects it to
160the file handle or file, depending on the type of I<$arg>. See the 162the file handle or file, depending on the type of I<$arg> (CODE reference,
161description of B<stdout> above. 163GLOB 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
182or changed later, using B<set_argv>, B<set_program>, B<set_input>, 184or changed later, using B<set_argv>, B<set_program>, B<set_input>,
183and B<set_timeout>. 185and B<set_timeout>.
184 186
185Monitors can be defined only when creating the object. 187Monitors 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
296Copyright (C) 2017 by Sergey Poznyakoff 298Copyright (C) 2017-2020 by Sergey Poznyakoff
297 299
298This library is free software; you can redistribute it and/or modify it 300This library is free software; you can redistribute it and/or modify it
299under the terms of the GNU General Public License as published by the 301under the terms of the GNU General Public License as published by the

Return to:

Send suggestions and report system problems to the System administrator.