Skip Menu |
 

This queue is for tickets about the Expect CPAN distribution.

Report information
The Basics
Id: 5570
Status: resolved
Priority: 0/
Queue: Expect

People
Owner: Nobody in particular
Requestors: bug [...] wingenbach.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: 1.17



Subject: expect dies as result of window resize
Download (untitled) / with headers
text/plain 1.3k
Following the example in the POD, resizing of the parent window causes the script to die. Use of uninitialized value in sysopen at /usr/lib/perl5/5.8.0/i586-linux-thread-multi/IO/File.pm line 159. Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site_perl/5.8.0/i586-linux-thread-multi/IO/Pty.pm line 76. Cannot open slave: No such file or directory at /home/jwing/bin/essh line 151 The failure appears to be related to IO::Pty. The following line does not return a tty value: my $tty = $master->ttyname(); A simple test of the expect new subroutine appears to show that the Pty is lost following the bless: New Function w/ prints: sub new { my ($class) = shift; $class = ref($class) if ref($class); # so we can be called as $exp->new() # Create the pty which we will use to pass process info. my($self) = new IO::Pty; die "$class: Could not assign a pty" unless $self; print "tty: ",$self->ttyname(),"\n"; bless $self => $class; print "tty: ",$self->ttyname(),"\n"; $self->autoflush(1); # This is defined here since the default is different for # initialized handles as opposed to spawned processes. ${*$self}{exp_Log_Stdout} = 1; $self->_init_vars(); if (@_) { # we got add'l parms, so pass them to spawn return $self->spawn(@_); } return $self; } Simple test script: #!/usr/bin/perl use Expect; $pty = new Expect; Execution: tty: /dev/pts/2 tty:
From: Robert Staats
[guest - Fri Mar 5 09:18:05 2004]: Here is a quick hack I did so the window resize would work for me. Not pretty but at least this can give you the functionality until a fix is posted. I had to modify Expect.pm and Pty.pm. Basically I add a global variable in Expect to record the ttyname, and modify Pty to read this var. Modify Expext.pm BEGIN { $Expect::VERSION = 1.15; # These are defaults which may be changed per object, or set as # the user wishes. # This will be unset, since the default behavior differs between # spawned processes and initialized filehandles. # $Expect::Log_Stdout = 1; $Expect::Log_Group = 1; $Expect::Debug = 0; $Expect::Exp_Max_Accum = 0; # unlimited $Expect::Exp_Internal = 0; $Expect::Manual_Stty = 0; $Expect::Multiline_Matching = 1; $Expect::Do_Soft_Close = 0; @Expect::Before_List = (); @Expect::After_List = (); %Expect::Spawned_PIDs = (); ########### # Added new var $Expect::Master_Pty; ########### } sub new { my ($class) = shift; $class = ref($class) if ref($class); # so we can be called as $exp- Show quoted text
>new()
# Create the pty which we will use to pass process info. my($self) = new IO::Pty; die "$class: Could not assign a pty" unless $self; ############### # Capture value of ttyname before we bless $Expect::Master_Pty = $self->ttyname(); ############### bless $self => $class; $self->autoflush(1); # This is defined here since the default is different for # initialized handles as opposed to spawned processes. ${*$self}{exp_Log_Stdout} = 1; $self->_init_vars(); if (@_) { # we got add'l parms, so pass them to spawn return $self->spawn(@_); } return $self; } sub _init_vars { my($self) = shift; # for every spawned process or filehandle. ${*$self}{exp_Log_Stdout} = $Expect::Log_Stdout if defined ($Expect::Log_Stdout); ${*$self}{exp_Log_Group} = $Expect::Log_Group; ${*$self}{exp_Debug} = $Expect::Debug; ${*$self}{exp_Exp_Internal} = $Expect::Exp_Internal; ${*$self}{exp_Manual_Stty} = $Expect::Manual_Stty; ${*$self}{exp_Stored_Stty} = 'sane'; ${*$self}{exp_Do_Soft_Close} = $Expect::Do_Soft_Close; # sysread doesn't like my or local vars. ${*$self}{exp_Pty_Buffer} = ''; # Initialize accumulator. ${*$self}{exp_Max_Accum} = $Expect::Exp_Max_Accum; ${*$self}{exp_Accum} = ''; ${*$self}{exp_NoTransfer} = 0; # create empty expect_before & after lists ${*$self}{exp_expect_before_list} = []; ${*$self}{exp_expect_after_list} = []; ################# # New var init ${*$self}{exp_Master_Pty} = $Expect::Master_Pty; ################# } Modify the IO::Pty.pm file and change the following sub: sub slave { @_ == 1 or croak 'usage: $pty->slave();'; my $master = shift; if (exists ${*$master}{'io_pty_slave'}) { return ${*$master}{'io_pty_slave'}; } #my $tty = $master->ttyname(); #<-- comment orignal line my $tty = ${*$master}{'exp_Master_Pty'}; #<-- Add new line my $slave = new IO::Tty; $slave->open($tty, O_RDWR | O_NOCTTY) || croak "Cannot open slave $tty: $!"; return $slave; }
From: Jeff Carr <basilarchia [...] gmail.com>
Download (untitled) / with headers
text/plain 125b
This problem is fixed in version IO-Tty-1.05 & Expect-1.16. svn co https://svn.sourceforge.net/svnroot/expectperl expectperl


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.