Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id:
16963
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
devil [...] ashes2ashes.de
Cc:
AdminCc:

BugTracker
Severity:
Normal
Broken in:
0.05
Fixed in:
(no value)



Subject: Cannot catch a timeout with SSH2->tcpip()
Distribution Net::SSH2-0.05 Perl: v5.8.0 built for i586-linux-thread-multi OS: linux 2.4.20-4GB #1 Wed Aug 6 18:26:21 UTC 2003 i586 My process tries to keep a ssh2 connection established. I use a tcpip() channel to connect to a service on the remote side. To make sure all is well i want to catch a possible timeout when creating this connection: eval { local $SIG{ALRM} = sub { die "timed out" }; alarm 3; $CurSSH2Channel = $CurSSH2->tcpip('127.0.0.1', $port); alarm 0; }; if i DO NOT set a local $SIG{ALRM}, my process dies completly (that's not what i want). If I set a local handler, the process continues with the tcpip() call, seemingly ignoring SIGALRM. Using a call like sleep(15) instead of SSH2->tcpip works fine. I don't see another way to check if the SSH2 connection is still up.
Sorry, I don't think I can help here. The tcpip() call happens almost entirely within the libssh2 library (libssh2_channel_direct_tcpip_ex), with no method to break into it should it take too long.
From: Guest
On Fr. 27. Jan. 2006, 21:29:19, DBROBINS wrote:
Show quoted text
> Sorry, I don't think I can help here. The tcpip() call happens almost > entirely within the libssh2 library (libssh2_channel_direct_tcpip_ex), > with no method to break into it should it take too long.
Sorry, my fault. I found the right way to do it, maybe this is helpful for someone else. As described in perlipc, sigaction should be used. use POSIX qw(sigaction); my $SignalSet = POSIX::SigSet->new(); my $SigAlrmAction = POSIX::SigAction->new('HandleAlrm', $SignalSet, &POSIX::SA_NODEFER); POSIX::sigaction(&POSIX::SIGALRM, $SigAlrmAction); sub HandleAlrm { # Whatever die ""; }


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

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