Skip Menu |

This queue is for tickets about the Net-SSH-Expect CPAN distribution.

Report information
The Basics
Id: 39777
Status: open
Priority: 0/
Queue: Net-SSH-Expect

People
Owner: Nobody in particular
Requestors: jpeshkin [...] impinj.com
Cc:
AdminCc:

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



Subject: Net:::SSH::Expect fails if perl threads are running
In the attached example, the script completes without error if the worker thread is not started. [Try changing the "if (1)" to "if (0)" to demonstrate]. If the thread is started, it fails with "SSHConnectionAborted" This has been seen on v5.8.5 built for i386-linux-thread-multi pre-installed on Centos 4.4 as well as on This is perl, v5.8.7 built for x86_64-linux-gnu-thread-multi (with 1 registered patch, see perl -V for more detail) from Ubuntu 6.06.1 _Dapper Drake_ - Release amd64
Subject: tbug.pl
use strict; use threads; use Net::SSH::Expect; my $w; if (1) { $w = threads->new(\&worker,{foo => 'bar'}) or die("thread creation failed"); } my $t = new Net::SSH::Expect( host => "myhost", user => "myuser", password => "mypassword", timeout => 5, raw_pty => 1 ); print "start login\n"; my $lo = $t->login(); print "end login\n"; sub worker { while (1) { sleep 10; } };
From: jpeshkin [...] impinj.com
Same problem seen on.... v5.10.0 built for i686-linux-thread-multi
From: Chris Foote <chris [...] foote.com.au>
On Thu Oct 02 13:59:33 2008, originalhack wrote: Show quoted text
> > In the attached example, the script completes without error if the > worker thread is not started. [Try changing the "if (1)" to "if (0)" to > demonstrate]. If the thread is started, it fails with > "SSHConnectionAborted"
Actually, I discovered this with the plain Expect module recently. It's caused by Expect doing a fork to create the pseudo-tty and expecting to be able to close the STDIN, STDOUT and STDERR file descriptors. If you have file descriptors open in threads, Expect can't close them. Perl threads inherit all open file descriptors. The workaround is to explicitly close STDIN, STDOUT & STDERR in your threads so that the Expect module is able to close them for its pseudo-tty handling. Cheers, Chris