I think you are running afowl of perl's "safe" signal handling. Read
about Perl Signal Handling and Oracle here: 

http://search.cpan.org/~lbaxter/Sys-SigAction/
In particular, look at
http://search.cpan.org/~lbaxter/Sys-SigAction/dbd-oracle-timeout.POD

This is referenced in the DBI/DBD::Oracle documentation.

Lincoln


On Wed, 2010-03-03 at 10:46 +0100, Hendrik Schumacher wrote:
> "use sigtrap" is probably executed at compile time and thus before the
> connect regardless of its location in the source code. You could try if
> your signal handler works during the readline if you set $SIG{'INT'} =
> 'SigExit'; (same for HUP and KILL) after the connect.
> 
> Hendrik
> 
> Am Di, 2.03.2010, 21:36, schrieb Steve Lynn:
> > On Mar 2, 2:30am, [email protected] (Martin Evans) wrote:
> >> Lynn, Steve wrote:
> >> > All - I'm under Solaris using perl v. 5.8.3 and DBI v. 1.48. I can
> >> catch signals w/o a problem before I connect to the database.
> >>
> >> > However after I connect, I can't catch signals anymore. If I comment
> >> out the "DBI->connect" and press ctrl-c in a ReadLine(0), the signal
> >> is caught fine.
> >>
> >> > I found one other issue that seemed similar
> >> (http://www.mail-archive.com/[email protected]/msg07747.html).
> >>
> >> > Please help.
> >>
> >> > ###########################
> >>
> >> > #!/usr/local/perl -w
> >>
> >> > use strict;
> >>
> >> > use warnings;
> >>
> >> > use Term:ReadKey;
> >>
> >> > require DBI;
> >>
> >> > use sigtrap 'handler', \&SigExit, qw/HUP INT KILL/;
> >>
> >> > my $dbh;
> >>
> >> > my $response;
> >>
> >> > sub SigExit {
> >>
> >> >   print STDOUT "\nTest\n";
> >>
> >> >   die("\n");
> >>
> >> > }
> >>
> >> > $dbh =
> >> DBI->connect("DBI:Oracle:host=dbserver;sid=mydb;port=1521","scott","tiger");
> >>
> >> > print "\nEnter a response: ";
> >>
> >> > $response = ReadLine(0);
> >>
> >> > print ""\nEnter another response: ";
> >>
> >> > $response = ReadLine(0);
> >>
> >> > ###########################
> >>
> >> > Thanks,
> >>
> >> > Steve
> >>
> >> Oracle client libraries can trap some signals (including HUP) depending
> >> on which ones you use and how you are connecting. I believe you will
> >> need to set up your handlers after connect for those signals but I
> >> cannot remember the down side in Oracle.
> >>
> >> There have been various posts on dbi-users about this in the past so an
> >> archive of dbi-users (some can be found at dbi.perl.org) would probably
> >> list them.
> >>
> >> Martin
> >> --
> >> Martin J. Evans
> >> Easysoft Limitedhttp://www.easysoft.com- Hide quoted text -
> >>
> >> - Show quoted text -
> >
> > Thanks Martin.
> >
> > I'm not sure whether I was clear enough on my goal.  I'm trying to
> > trap INT signals so that when requesting input from the operator with
> > ReadLine, they can press ctrl-c and exit.  I don't like the default
> > signal handling so I'd like to just do a die("\n") when an INT is
> > received.
> >
> > When I comment out the DBI->connect, a ctrl-c will exit from the
> > ReadLine as intended.  However, once the DBI->connect is completed,
> > and the operator presses ctrl-c within the ReadLine, '^C' appears, but
> > the signal handler isn't called.  It looks like the DBI->connect
> > cancels, disables or overrides my sigtrap.
> >
> > I'm not trying to handle any signals from within DBI.  I just trying
> > to handle INT from within ReadLine.  It seems like DBI->connect is
> > canceling my signal handler.
> >
> > I tried to reload sigtrap immediately after the DBI->connect but that
> > didn't work either:
> >
> > #!/usr/local/perl -w
> >
> > use strict;
> > use warnings;
> > use Term:ReadKey;
> > require DBI;
> >
> > use sigtrap 'handler', \&SigExit, qw/HUP INT KILL/;
> >
> > my $dbh;
> > my $response;
> >
> > sub SigExit {
> >     print STDOUT "\nTest\n";
> >     die("\n");
> > }
> >
> > $dbh = DBI-
> >>connect("DBI:Oracle:host=dbserver;sid=mydb;port=1521","scott","tiger");
> >
> > use sigtrap 'handler', \&SigExit, qw/HUP INT KILL/;
> >
> > print "\nEnter a response: ";
> > $response = ReadLine(0);
> >
> > print ""\nEnter another response: ";
> > $response = ReadLine(0);
> >
> > ##################################
> >
> > Any help would be appreciated,
> >
> > Steve Lynn
> >
> >
> 
> 

Reply via email to