DBI, CGI and killing child processes

DBI, CGI and killing child processes

am 28.09.2005 15:28:01 von jan.aerts

Hi,

I've written a CGI script that connects to a Postgres database, performs =
a query, and displays the results on a webpage. The CGI script is run as =
user nobody, but the actual connection to the database is run by user =
postgres.
The actual query can take a long time to run, resulting in the end-user =
sometimes hitting the Escape button in his webbrowser. Unfortunately, a =
problem arises when he/she does that while the query is running. =
Pressing the button will stop the CGI script from running, but will not =
kill the query itself. What I end up with, is a rogue process that can =
only be killed by our system administrator.

In the script, I basically do this:
* my $dbh =3D DBI->connect("dbi:Pg:dbname=3Dblabla;host=3Dlocalhost", =
$user, $password, { AutoCommit =3D> 0, RaiseError =3D> 1 });
* my $sth =3D $dbh->prepare("SELECT id, object1_id, object1_name, =
relationship_name, object2_id, object2_name FROM c_relationships");
* $sth->execute();
* $sth->bind_columns( \$id, \$object1_id, \$object1_name, =
\$relationship_name, \$object2_id, \$object2_name );
* while ( $sth->fetch ) { do_some_stuff };
* $dbh->disconnect();

Does anyone have an idea how I can automatically kill any child =
processes when the CGI script is killed?

Thanks very much,
jan.

---------The obligatory disclaimer--------
The information contained in this e-mail (including any attachments) is =
confidential and is intended for the use of the addressee only. The =
opinions expressed within this e-mail (including any attachments) are =
the opinions of the sender and do not necessarily constitute those of =
Roslin Institute (Edinburgh) ("the Institute") unless specifically =
stated by a sender who is duly authorised to do so on behalf of the =
Institute.=20