From: John W. <exp...@wi...> - 2004-05-26 13:13:44
|
After much fun, I have found the solution to a bug in Expect.pm. The problem surfaces in the attempt to retrieve a slave (e.g. clone_winsize_from): from IO::Pty: 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(); my $slave = new IO::Tty; $slave->open($tty, O_RDWR | O_NOCTTY) || croak "Cannot open slave $tty: $!"; return $slave; } Note that the creation of the slave (assuming the if test fails), is dependent upon retrieving the ttyname. However, Expect.pm "use"s both POSIX and IO::Pty. The problem with the default 'use POSIX;' is that POSIX also has a ttyname declaration and thus once an Expect object is blessed, the ttyname function used is NOT the IO::Pty one. The solution is to limit what is being incorporated into Expect from the POSIX module. From my limited tests, I have been able successfully change the use line to: use POSIX qw (WNOHANG); With this change, the ttyname function can be called and the name retrieved. Thus, window resizing: $e = new Expect; $e->slave->clone_winsize_from(\*STDIN); $SIG{WINCH} = \&winch; sub winch { $e->slave->clone_winsize_from(\*STDIN); kill WINCH => $e->pid if $e->pid; $SIG{WINCH} = \&winch; } works as well as any other call which needs to retrieve the ttyname from the expect object. Cheers, John C. Wingenbach PS... I am assuming that the authors/maintainers of Expect are no longer active as I have not seen any kind of involvement from them on the lists nor on CPAN. Is Expect.pm a dead or orphaned module? |