If this is on Windows... Sys::SigAction will not help you. sigaction()
is a POSIX (unix) function for signal handling.

On most *ix flavored of OSes, Sys:SigAction will probably get your alarm
to fire.  And make it easy to setup. There is a sample oracle test
script in the kit which illustrates its use.  

Background: I ran into exactly this problem when I upgraded to perl
5.8.0 a year ago.  Took me nine-months... intermittently to figure out
what was happening.  At first I thought the problem was Oracle 9i. It
was actually the combination of the interaction of how perl changed
default signal handling (to make it "safe"), the way oracle OCI was
calling the connect() system call (restartably).  truss (solaris), or
strace (gnu/linux) should show you the system calls being made, and be
very revealing of what is really going on.

http://search.cpan.org/~lbaxter/Sys-SigAction/

Lincoln

On Fri, 2004-08-27 at 20:43, Henri Asseily wrote:
> Try to use "RaiseError => 1", otherwise the DBI connect won't die and 
> the alarm won't be triggered. Or modify your connect statement to be:
> 
> DBI->connect("dbi:ODBC:GARDEL","Gardel","Gardel",{RaiseError => 0}) or 
> die "DBI->errstr";
> 
> Also try to use the Sys::SigAction module by Lincoln Baxter and report 
> back. It abstracts all sorts of problems that different versions of Perl 
> have with signal handling. I've used it successfully when other methods 
> have failed.
> 
> Caveat: I've never used DBI and ODBC on Win32, and I've never 
> encountered a modal dialog box.
> 
> Arias, Esteban Ariel wrote:
> 
> > Hi:
> > 
> > This is an extract of test code of what IÂm doing:
> > 
> > use Carp;
> > use DBI;
> > use Data::Dumper;
> > 
> > my $self = {};
> > 
> > eval { 
> >     local $SIG{ALRM} = sub { die "TIMEOUT"; }; 
> >     alarm 3; 
> >     
> >     $self->{DBH} =
> > DBI->connect("dbi:ODBC:GARDEL","Gardel","Gardel",{RaiseError => 0});
> > }; 
> > alarm 0;
> > 
> > print Dumper ($self->{DBH}), " ", DBI->err, " ",DBI->errstr, "\n";
> > 
> > The problem is that when I try to connect to the database through DBI and
> > there is no network, a message box appears saying:
> > 
> > 10065 WSA E HostUnreach: The Teradata server can't currently be reached over
> > this network.
> > 
> > Furthermore the alarm sign doesnÂt execute, and only when I hit OK button in
> > the message box, the execution thread goes off the scope of the eval (exits)
> > and just in that moment the message in the command line appears(print Dumper
> > ...).
> > 
> > I would rather prefer:
> > 1) that the message box doesnÂt appear, which it would imply that the alarm
> > would ring. OR
> > 2) If there is no way to override the message box, to automatically "HIT"
> > the OK Button.
> > 
> > Thanks in advance.
> > 
> > 
> > 
> > 
> 

Reply via email to