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? |
From: Roland G. <RGi...@cp...> - 2004-05-26 13:41:22
|
Thanks for the fix. I hope I will find the time to check what exactly is needed from the POSIX module (can't remember offhand). Unfortunately my current working and personal situation does not leave time for much maintainance, but rest assured that Expect and IO::Pty are NOT orphaned. :o) I will try to create a new release in the next few days (there are several fixes waiting to be released). Roland John Wingenbach wrote: > 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? > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |
From: Austin S. <te...@of...> - 2004-05-26 15:45:24
|
On Wed, May 26, 2004 at 03:40:50PM +0200, Roland Giersig wrote: > Thanks for the fix. I hope I will find the time to check what exactly is > needed from the POSIX module (can't remember offhand). > setsid(), specifically. IO::Stty also uses POSIX for the termio stuff. Austin |
From: Austin S. <te...@of...> - 2004-05-26 19:35:29
|
On Wed, May 26, 2004 at 09:13:27AM -0400, John Wingenbach wrote: > > 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: > Seems to me, after thinking about this for a bit, that IO::Pty::ttyname and POSIX::ttyname should do exactly the same thing. If POSIX::ttyname isn't returning correctly it seems like we should patch it. One of the issues is that it probably doesn't like filehandle refs, but that would probably be an easy fix. Austin |