mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
e49c1d1cef
prevents buffering in cases like ./mtr | tee log
25 lines
349 B
Perl
25 lines
349 B
Perl
package My::Tee;
|
|
use IO::Handle;
|
|
|
|
# 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;
|
|
$fh->flush;
|
|
print $copyfh $buf;
|
|
return length($buf);
|
|
}
|
|
|
|
1;
|