RE: Signal Handling

From: Timothy Helck (Timothy.Helck_at_bowker.com)
Date: 12/16/03


Date: Tue, 16 Dec 2003 14:04:14 -0500
To: "Khamneian, Mahtaj" <khamneianm@umsystem.edu>,	<dbi-users@perl.org>

I'm not able to reproduce your results.

Does ctrl-C kill the perl process and leave the select running, or does it fail to kill the perl?

Does ctrl-C work if you change any of the following?
        remove sleep()
        remove distinct from the query
        replace dump_results() with bind_columns() and fetch()
        

-----Original Message-----
From: Khamneian, Mahtaj [mailto:khamneianm@umsystem.edu]
Sent: Tuesday, December 16, 2003 11:36 AM
To: dbi-users@perl.org
Subject: RE: Signal Handling

Thanks for the reply.
I have tried a slight variation of what you've suggested, but it seems, the db operation is not cancelled as a result of hitting
CTRL-C-- I have to kill the process manually to stop the program.
Here's a snippet of the program:
...
sub kill_me{my $key = shift; die "\n\n\tKilled:$key\n\n";}
$SIG{INT} = \&kill_me;

DBI->trace (0);

# connect to target db
my $dbh = DBI->connect ("dbi:Oracle:$sid", $user, $password)
        or die "Can't connect to database: $DBI::errstr\n";

my $sth = $dbh->prepare( "select distinct sid, status, client_info, b.name, b.emailid from
v\$session, ps_um_employees b where substr(client_info,1,(instr(client_info,',')-1))=b.mang
led_sso (+) and status='ACTIVE'" );

while (1) {
   $sth->execute();
   my $rows = $sth->dump_results();

   sleep(5);
}

$dbh->disconnect;

exit 0;

> -----Original Message-----
> From: Helck, Timothy [mailto:Timothy.Helck@bowker.com]
> Sent: Tuesday, December 16, 2003 7:51 AM
> To: Khamneian, Mahtaj; dbi-users@perl.org
> Subject: RE: Signal Handling
>
>
> I'm not sure if this is what you have in mind:
>
> sub kill_me{my $key = shift; die "\n\n\tKilled:$key\n\n";}
> $SIG{INT} = \&kill_me;
>
> This will kill the Perl process and (I think) any child processes.
>
>
> -----Original Message-----
> From: Khamneian, Mahtaj [mailto:khamneianm@umsystem.edu]
> Sent: Monday, December 15, 2003 4:17 PM
> To: dbi-users@perl.org
> Subject: Signal Handling
>
>
> Has anyone been able to successfully implement CTRL-C signal
> handling in Perl DBI?
> If so, I'd appreciate an example.
>
> -------------------------------------
> Mahtaj Khamneian
> University of Missouri - ASP Phone : (573) 884-2281
> 1805 East Walnut Fax : (573)
> 884-3070
> Columbia, MO 65201-6425 khamneianm@missouri.edu
> I wish I were able to create a program that could ping my mind.
> I would then load it into the creation's/nature's server, for which
> no root access is needed, and invoke it via cron at spontaneous
> intervals.
>
>



Relevant Pages

  • RE: Signal Handling
    ... CTRL-C-- I have to kill the process manually to stop the program. ... > This will kill the Perl process and any child processes. ... > Subject: Signal Handling ... > I wish I were able to create a program that could ping my mind. ...
    (perl.dbi.users)
  • RE: Signal Handling
    ... Both the SELECT in the database and the perl process continue to run after CTRL-C. ... I have to do a "kill pid" from the shell to stop the execution in both places. ...
    (perl.dbi.users)
  • Re: Cut, Copy, Paste Nightmare
    ... I expect control-c to interrupt and kill an application as it has ... CTRL-C in a terminal window kills the running program launched from that ... CTRL-C doesn't kill the ... as my experience was with terminals connected to mainframe systems. ...
    (Fedora)
  • Re: Controlling (La)TeX
    ... While I definitely agree that a program shouldn't trap the interrupt and ... occasional infinite loops) instead of just quitting the program entirely. ... But it wouldn't be any feat of magic to have ^C kill the ... it should be assigned to ctrl-c. ...
    (comp.text.tex)
  • Re: [SLE] lsof -> grep hangs?
    ... > will not terminate, and needs a ctrl-C to kill it. ... > Can someone running 9.1 test with this command in a ... > If it does not return to the prompt you might need Ctrl-C to kill it. ...
    (SuSE)