$VERSION = '3.038'; # $Id: //depot/Tk8/IO/IO.pm#38 $
use Tk::Event qw($XS_VERSION);
use base qw(DynaLoader IO::Handle);
my ($package,%args) = @_;
# Do whatever IO::Handle does
my $fh = $package->SUPER::new
;
%{*$fh} = (); # The hash is used for configure options
${*$fh} = ''; # The scalar is used as the 'readable' buffer
@
{*$fh} = (); # The array
foreach $key (keys %args)
$val = Tk
::Callback
->new($val) if ($key =~ /command$/);
croak
'No child' unless (defined $pid);
croak
'No child' unless (defined $pid);
kill($sig,$pid) || croak
"Cannot kill($sig,$pid):$!";
my $count = sysread($fh,${*$fh},1,length(${*$fh}));
if (exists ${*$fh}{-errorcommand
})
${*$fh}{-errorcommand
}->Call($!);
warn "Cannot read $fh:$!";
if (exists ${*$fh}{-linecommand
})
my $eol = index(${*$fh},"\n");
my $line = substr(${*$fh},0,++$eol);
substr(${*$fh},0,$eol) = '';
${*$fh}{-linecommand
}->Call($line);
my $cmd = ${*$fh}{'-exec'};
return (wantarray) ? @
$cmd : $cmd;
my $pid = open($fh,'-|');
${*$fh} = '' unless (defined ${*$fh});
if (exists ${*$fh}{-linecommand
})
my $w = ${*$fh}{-widget
};
$w = 'Tk' unless (defined $w);
$w->fileevent($fh,'readable',[$fh,'readable']);
croak Tk
::Pretty
::Pretty
(\
%{*$fh});
# make STDERR same as STDOUT here
exec(@_) || die 'Cannot exec ',join(' ',@_),":$!";
my $ch = delete ${*$fh}{-childcommand
};
${*$fh}{-childcommand
} = Tk
::Callback
->new(sub { $code = shift });
Tk
::Event
::DoOneEvent
(0) until (defined $code);
${*$fh}{-childcommand
} = $ch;
my $w = delete ${*$fh}{_readable
};
$w->fileevent($fh,'readable','') if (defined $w);
if (exists ${*$fh}{-childcommand
})
${*$fh}{-childcommand
}->Call($?
,$fh);