my $out = shift @ARGV;
die unless @ARGV;
-open my $fout, ">>", $out or die if $out;
+open my $fout, ">>", $out or die "Can't write to $out: $!" if $out;
my $select = IO::Select->new();
my $alive = 1;
my $pid;
+my $interactive = -t STDOUT;
my $code;
sub sigchld
}
$SIG{CHLD} = \&sigchld;
-$pid = open3( \*child_in, \*child_out, \*child_err, @ARGV );
-close child_in;
+$pid = open3( "<&STDIN", \*child_out, \*child_err, @ARGV );
sub sethandle
{
while ( $alive ) {
foreach my $h ( $select->can_read() ) {
- sysread $h, $_, 1024;
+ sysread $h, $_, 102400;
print $fout $_ if $fout;
- if ( $h == \*child_err ) {
+ if ( $interactive && $h == \*child_err ) {
print "\033[31m$_\033[0m";
} else {
print $_;