summaryrefslogtreecommitdiff
path: root/mysql-test/lib
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-02-22 08:39:24 +0100
committerSergei Golubchik <serg@mariadb.org>2018-02-22 08:39:24 +0100
commit2daa00580096fc825dadcab7f04cfd5a8069927f (patch)
treefb6d7187b0289ad6ae95f60aa193bb39d25e46f8 /mysql-test/lib
parentdb0484f355dae8d3a4e4aab731522521e8ff976e (diff)
parent5d8ac1ece1687278cbc860e97eae9c7cc163ee73 (diff)
downloadmariadb-git-2daa00580096fc825dadcab7f04cfd5a8069927f.tar.gz
Merge branch '10.1' into 10.2
Diffstat (limited to 'mysql-test/lib')
-rw-r--r--mysql-test/lib/My/SafeProcess/Base.pm12
-rw-r--r--mysql-test/lib/My/Tee.pm23
2 files changed, 31 insertions, 4 deletions
diff --git a/mysql-test/lib/My/SafeProcess/Base.pm b/mysql-test/lib/My/SafeProcess/Base.pm
index 1ac0120a735..c5ac2ab51c2 100644
--- a/mysql-test/lib/My/SafeProcess/Base.pm
+++ b/mysql-test/lib/My/SafeProcess/Base.pm
@@ -186,8 +186,10 @@ sub create_process {
# it and any childs(that hasn't changed group themself)
setpgrp(0,0) if $opts{setpgrp};
- if ( $output and !open(STDOUT, $open_mode, $output) ) {
- croak("can't redirect STDOUT to '$output': $!");
+ if ( $output ) {
+ close STDOUT;
+ open(STDOUT, $open_mode, $output)
+ or croak "can't redirect STDOUT to '$output': $!";
}
if ( $error ) {
@@ -196,8 +198,10 @@ sub create_process {
croak("can't dup STDOUT: $!");
}
}
- elsif ( ! open(STDERR, $open_mode, $error) ) {
- croak("can't redirect STDERR to '$error': $!");
+ else {
+ close STDERR;
+ open(STDERR, $open_mode, $error)
+ or croak "can't redirect STDERR to '$error': $!";
}
}
diff --git a/mysql-test/lib/My/Tee.pm b/mysql-test/lib/My/Tee.pm
new file mode 100644
index 00000000000..ee82e6f45ae
--- /dev/null
+++ b/mysql-test/lib/My/Tee.pm
@@ -0,0 +1,23 @@
+package My::Tee;
+
+# see PerlIO::via
+
+our $copyfh;
+
+sub PUSHED
+{
+ open($copyfh, '>', "$::opt_vardir/log/stdout.log")
+ or die "open(>$::opt_vardir/log/stdout.log): $!"
+ unless $copyfh;
+ bless { }, shift;
+}
+
+sub WRITE
+{
+ my ($obj, $buf, $fh) = @_;
+ print $fh $buf;
+ print $copyfh $buf;
+ return length($buf);
+}
+
+1;