| 1 | package App::Tel::Expect; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | App::Tel::Expect - Monkeypatching Expect to support callbacks and large buffer reads | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use POSIX qw(:sys_wait_h :unistd_h); # For WNOHANG and isatty | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 7 | $Expect::read_buffer_size = 10240; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | *Expect::set_cb = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | my ( $self, $object, $function, $params, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | # Set an escape sequence/function combo for a read handle for interconnect. | ||||||||||||||||||||||||||||||||||||||||||
| 20 | # Ex: $read_handle->set_seq('',\&function,\@parameters); | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ${ ${*$object}{exp_cb_Function} } = $function; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | if ( ( !defined($function) ) || ( $function eq 'undef' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $function or $function eq "undef"
MC/DC0%0/2
not defined $function or $function eq "undef"
not defined $function
$function eq "undef"
Truth table0%0/3
not(A) or B
A= not defined $functionB= $function eq "undef"
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ${ ${*$object}{exp_cb_Function} } = \&_undef; | |||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ${ ${*$object}{exp_cb_Parameters} } = $params; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 7 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | *Expect::interconnect = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=49 SCAR=78.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my (@handles) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | # my ($handle)=(shift); call as Expect::interconnect($spawn1,$spawn2,...) | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my ( $nread ); | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my ( $rout, $emask, $eout ); | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my ( $escape_character_buffer ); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my ( $read_mask, $temp_mask ) = ( '', '' ); | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | # Get read/write handles | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | foreach my $handle (@handles) { | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $temp_mask = ''; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | vec( $temp_mask, $handle->fileno(), 1 ) = 1; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | # Under Linux w/ 5.001 the next line comes up w/ 'Uninit var.'. | ||||||||||||||||||||||||||||||||||||||||||
| 44 | # It appears to be impossible to make the warning go away. | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # doing something like $temp_mask='' unless defined ($temp_mask) | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # has no effect whatsoever. This may be a bug in 5.001. | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $read_mask = $read_mask | $temp_mask; | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ($Expect::Debug) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | print STDERR "Read handles:\r\n"; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | foreach my $handle (@handles) { | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | print STDERR "\tRead handle: "; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | print STDERR "'${*$handle}{exp_Pty_Handle}'\r\n"; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | print STDERR "\t\tListen Handles:"; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | foreach my $write_handle ( @{ ${*$handle}{exp_Listen_Group} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | print STDERR " '${*$write_handle}{exp_Pty_Handle}'"; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | print STDERR ".\r\n"; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | # I think if we don't set raw/-echo here we may have trouble. We don't | ||||||||||||||||||||||||||||||||||||||||||
| 63 | # want a bunch of echoing crap making all the handles jabber at each other. | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | foreach my $handle (@handles) { | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | unless ( ${*$handle}{"exp_Manual_Stty"} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | # This is probably O/S specific. | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ${*$handle}{exp_Stored_Stty} = $handle->exp_stty('-g'); | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | print STDERR "Setting tty for ${*$handle}{exp_Pty_Handle} to 'raw -echo'.\r\n" | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ${*$handle}{"exp_Debug"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $handle->exp_stty("raw -echo"); | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | foreach my $write_handle ( @{ ${*$handle}{exp_Listen_Group} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | unless ( ${*$write_handle}{"exp_Manual_Stty"} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ${*$write_handle}{exp_Stored_Stty} = | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $write_handle->exp_stty('-g'); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | print STDERR "Setting ${*$write_handle}{exp_Pty_Handle} to 'raw -echo'.\r\n" | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if ${*$handle}{"exp_Debug"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $write_handle->exp_stty("raw -echo"); | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | print STDERR "Attempting interconnection\r\n" if $Expect::Debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | # Wait until the process dies or we get EOF | ||||||||||||||||||||||||||||||||||||||||||
| 87 | # In the case of !${*$handle}{exp_Pid} it means | ||||||||||||||||||||||||||||||||||||||||||
| 88 | # the handle was exp_inited instead of spawned. | ||||||||||||||||||||||||||||||||||||||||||
| 89 | CONNECT_LOOP: | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | # Go until we have a reason to stop | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | # test each handle to see if it's still alive. | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | foreach my $read_handle (@handles) { | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | waitpid( ${*$read_handle}{exp_Pid}, WNOHANG ) | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | if ( exists( ${*$read_handle}{exp_Pid} ) | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | and ${*$read_handle}{exp_Pid} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists do {
*$read_handle
}->{"exp_Pid"} and do {
*$read_handle
}->{"exp_Pid"}
MC/DC0%0/2
exists do {
*$read_handle
}->{"exp_Pid"} and do {
*$read_handle
}->{"exp_Pid"}
exists do {
*$read_handle
}->{"exp_Pid"}
do {
*$read_handle
}->{"exp_Pid"}
Truth table0%0/3
A and B
A= exists do {
*$read_handle
}->{"exp_Pid"}B= do {
*$read_handle
}->{"exp_Pid"}
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if ( exists( ${*$read_handle}{exp_Pid} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists do {
*$read_handle
}->{"exp_Pid"} and do {
*$read_handle
}->{"exp_Pid"} and not kill(0, do {
*$read_handle
}->{"exp_Pid"})
exists do {
*$read_handle
}->{"exp_Pid"} and do {
*$read_handle
}->{"exp_Pid"}
MC/DC0%0/3
exists do {
*$read_handle
}->{"exp_Pid"} and do {
*$read_handle
}->{"exp_Pid"} and not kill(0, do {
*$read_handle
}->{"exp_Pid"})
exists do {
*$read_handle
}->{"exp_Pid"}
do {
*$read_handle
}->{"exp_Pid"}
not kill(0, do {
*$read_handle
}->{"exp_Pid"})
Truth table0%0/4
A and B and not(C)
A= exists do {
*$read_handle
}->{"exp_Pid"}B= do {
*$read_handle
}->{"exp_Pid"}C= not kill(0, do {
*$read_handle
}->{"exp_Pid"})
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | and ( ${*$read_handle}{exp_Pid} ) | |||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | and ( !kill( 0, ${*$read_handle}{exp_Pid} ) ) ) | |||||||||||||||||||||||||||||||||||||||||
| 102 | { | ||||||||||||||||||||||||||||||||||||||||||
| 103 | print STDERR | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | "Got EOF (${*$read_handle}{exp_Pty_Handle} died) reading ${*$read_handle}{exp_Pty_Handle}\r\n" | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ${*$read_handle}{"exp_Debug"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | last CONNECT_LOOP | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | unless defined( ${ ${*$read_handle}{exp_Function} }{"EOF"} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | last CONNECT_LOOP | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | unless &{ ${ ${*$read_handle}{exp_Function} }{"EOF"} } | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | ( @{ ${ ${*$read_handle}{exp_Parameters} }{"EOF"} } ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | # Every second? No, go until we get something from someone. | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $nfound = select( $rout = $read_mask, undef, $eout = $emask, undef ); | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | # Is there anything to share? May be -1 if interrupted by a signal... | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | next CONNECT_LOOP if not defined $nfound or $nfound < 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $nfound or $nfound < 1
MC/DC0%0/2
not defined $nfound or $nfound < 1
not defined $nfound
$nfound < 1
Truth table0%0/3
not(A) or B
A= not defined $nfoundB= $nfound < 1
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | # Which handles have stuff? | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my @bits = split( //, unpack( 'b*', $rout ) ); | |||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | $eout = 0 unless defined($eout); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my @ebits = split( //, unpack( 'b*', $eout ) ); | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | # print "Ebits: $eout\r\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | foreach my $read_handle (@handles) { | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ( $bits[ $read_handle->fileno() ] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | $nread = sysread( | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $read_handle, ${*$read_handle}{exp_Pty_Buffer}, | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $Expect::read_buffer_size | |||||||||||||||||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if (${*$read_handle}{exp_cb_Function}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | &{ ${ ${*$read_handle}{exp_cb_Function} } }( @{ ${ ${*$read_handle}{exp_cb_Parameters} } } ) | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | # Appease perl -w | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | $nread = 0 unless defined($nread); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | print STDERR "interconnect: read $nread byte(s) from ${*$read_handle}{exp_Pty_Handle}.\r\n" | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if ${*$read_handle}{"exp_Debug"} > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | # Test for escape seq. before printing. | ||||||||||||||||||||||||||||||||||||||||||
| 143 | # Appease perl -w | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | $escape_character_buffer = '' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | unless defined($escape_character_buffer); | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $escape_character_buffer .= ${*$read_handle}{exp_Pty_Buffer}; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | foreach my $escape_sequence ( keys( %{ ${*$read_handle}{exp_Function} } ) ) { | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | print STDERR "Tested escape sequence $escape_sequence from ${*$read_handle}{exp_Pty_Handle}" | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ${*$read_handle}{"exp_Debug"} > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | # Make sure it doesn't grow out of bounds. | ||||||||||||||||||||||||||||||||||||||||||
| 152 | $escape_character_buffer = $read_handle->_trim_length( | ||||||||||||||||||||||||||||||||||||||||||
| 153 | $escape_character_buffer, | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ${*$read_handle}{"exp_Max_Accum"} | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | ) if ( ${*$read_handle}{"exp_Max_Accum"} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if ( $escape_character_buffer =~ /($escape_sequence)/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $match = $1; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if ( ${*$read_handle}{"exp_Debug"} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | print STDERR | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | "\r\ninterconnect got escape sequence from ${*$read_handle}{exp_Pty_Handle}.\r\n"; | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | # I'm going to make the esc. seq. pretty because it will | ||||||||||||||||||||||||||||||||||||||||||
| 163 | # probably contain unprintable characters. | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | print STDERR "\tEscape Sequence: '" | |||||||||||||||||||||||||||||||||||||||||
| 165 | . _trim_length( | ||||||||||||||||||||||||||||||||||||||||||
| 166 | undef, | ||||||||||||||||||||||||||||||||||||||||||
| 167 | _make_readable($escape_sequence) | ||||||||||||||||||||||||||||||||||||||||||
| 168 | ) . "'\r\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | print STDERR "\tMatched by string: '" . _trim_length( undef, _make_readable($match) ) . "'\r\n"; | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | # Print out stuff before the escape. | ||||||||||||||||||||||||||||||||||||||||||
| 173 | # Keep in mind that the sequence may have been split up | ||||||||||||||||||||||||||||||||||||||||||
| 174 | # over several reads. | ||||||||||||||||||||||||||||||||||||||||||
| 175 | # Let's get rid of it from this read. If part of it was | ||||||||||||||||||||||||||||||||||||||||||
| 176 | # in the last read there's not a lot we can do about it now. | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ( ${*$read_handle}{exp_Pty_Buffer} =~ /([\w\W]*)($escape_sequence)/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $read_handle->_print_handles($1); | |||||||||||||||||||||||||||||||||||||||||
| 179 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $read_handle->_print_handles( ${*$read_handle}{exp_Pty_Buffer} ); | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | # Clear the buffer so no more matches can be made and it will | ||||||||||||||||||||||||||||||||||||||||||
| 184 | # only be printed one time. | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ${*$read_handle}{exp_Pty_Buffer} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $escape_character_buffer = ''; | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | # Do the function here. Must return non-zero to continue. | ||||||||||||||||||||||||||||||||||||||||||
| 189 | # More cool syntax. Maybe I should turn these in to objects. | ||||||||||||||||||||||||||||||||||||||||||
| 190 | last CONNECT_LOOP | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | unless &{ ${ ${*$read_handle}{exp_Function} }{$escape_sequence} } | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | ( @{ ${ ${*$read_handle}{exp_Parameters} }{$escape_sequence} } ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | $nread = 0 unless defined($nread); # Appease perl -w? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | waitpid( ${*$read_handle}{exp_Pid}, WNOHANG ) | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | if ( defined( ${*$read_handle}{exp_Pid} ) | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | && ${*$read_handle}{exp_Pid} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined do {
*$read_handle
}->{"exp_Pid"} and do {
*$read_handle
}->{"exp_Pid"}
MC/DC0%0/2
defined do {
*$read_handle
}->{"exp_Pid"} and do {
*$read_handle
}->{"exp_Pid"}
defined do {
*$read_handle
}->{"exp_Pid"}
do {
*$read_handle
}->{"exp_Pid"}
Truth table0%0/3
A and B
A= defined do {
*$read_handle
}->{"exp_Pid"}B= do {
*$read_handle
}->{"exp_Pid"}
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | if ( $nread == 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | print STDERR "Got EOF reading ${*$read_handle}{exp_Pty_Handle}\r\n" | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ${*$read_handle}{"exp_Debug"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | last CONNECT_LOOP | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | unless defined( ${ ${*$read_handle}{exp_Function} }{"EOF"} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | last CONNECT_LOOP | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | unless &{ ${ ${*$read_handle}{exp_Function} }{"EOF"} } | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | ( @{ ${ ${*$read_handle}{exp_Parameters} }{"EOF"} } ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | last CONNECT_LOOP if ( $nread < 0 ); # This would be an error | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $read_handle->_print_handles( ${*$read_handle}{exp_Pty_Buffer} ); | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | # I'm removing this because I haven't determined what causes exceptions | ||||||||||||||||||||||||||||||||||||||||||
| 213 | # consistently. | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | if (0) #$ebits[$read_handle->fileno()]) | |||||||||||||||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||||||||||||||||
| 216 | print STDERR "Got Exception reading ${*$read_handle}{exp_Pty_Handle}\r\n" | ||||||||||||||||||||||||||||||||||||||||||
| 217 | if ${*$read_handle}{"exp_Debug"}; | ||||||||||||||||||||||||||||||||||||||||||
| 218 | last CONNECT_LOOP | ||||||||||||||||||||||||||||||||||||||||||
| 219 | unless defined( ${ ${*$read_handle}{exp_Function} }{"EOF"} ); | ||||||||||||||||||||||||||||||||||||||||||
| 220 | last CONNECT_LOOP | ||||||||||||||||||||||||||||||||||||||||||
| 221 | unless &{ ${ ${*$read_handle}{exp_Function} }{"EOF"} } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | ( @{ ${ ${*$read_handle}{exp_Parameters} }{"EOF"} } ); | ||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | foreach my $handle (@handles) { | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | unless ( ${*$handle}{"exp_Manual_Stty"} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $handle->exp_stty( ${*$handle}{exp_Stored_Stty} ); | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | foreach my $write_handle ( @{ ${*$handle}{exp_Listen_Group} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | unless ( ${*$write_handle}{"exp_Manual_Stty"} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $write_handle->exp_stty( ${*$write_handle}{exp_Stored_Stty} ); | |||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||