All - I'm running Perl 5.6.0 and DBI 1.14 under Win2k. I've got a problem
with signals. It seems as if I can't catch any signals (e.g., Ctrl-C) after
making a connection to my database (MySQL). I need to manually use the Task
Manager (Ctrl - Alt - Del) to stop the process.
I've deleted all unnecessary code, including the database query itself (yes,
the same problem occurs if a query is left in place). If I comment out the
connect and disconnect statements, I don't have any problems catching the
signal.
I need this set up inside the while loop because this code will eventually
be part of a server, accepting client connections from Perl and C++ clients.
Any suggestions?
Thanks,
Mark
*
Here's the code I'm running (it will run if you adjust $dbstring, user, and
password):
#!perl -w
use strict;
use diagnostics;
use DBI;
my $quit = 0;
$SIG{INT} = \catch_int;
while (!$quit) {
print in while()\n;
my $result = query_db();
print $result;
sleep(2);
}
sub query_db {
# Build the database connection string.
my $dbstring = DBI:mysql:database01:127.0.0.1:3306;
# Connect to the database.
my $dbh = DBI-connect($dbstring,user,password)
or die Can't connect to mysql on 127.0.0.1: $DBI::errstr\n;
# Assume result from the db is named result.
my $result = Test;
print Disconnecting \$dbh\n;
$dbh-disconnect;
return ($result);
}
sub catch_int {
my $sig = shift;
print Caught $sig\n;
$quit++;
}
--
Mark Riehl
Agile Communications, Inc.
Email: [EMAIL PROTECTED]