in reply to alarm not working
So I guess, your problem is that $socket_resp->recv($recieved_data,1024); blocks until it receives 1024 bytes. Try adding Blocking => 0 to IO::Socket::INET->new() arguments. You would also probably want to substitute my $port = shift; with my $recv_port = shift; (use warnings; warned about it).#!/usr/bin/perl eval { local $SIG{ALRM} = sub { die "Timed Out"; }; alarm 3; sleep 1 while 1; alarm 0; }; alarm 0; if ($@ =~ /Timed Out/i) { print "Timed-Out waiting for infinite loop to finish\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: alarm not working
by anshumangoyal (Scribe) on Jul 12, 2012 at 16:35 UTC | |
by aitap (Curate) on Jul 13, 2012 at 17:17 UTC |