develooper Front page | perl.libwww | Postings from January 2002

problem using perl debugger with HTTP::Daemon

From:
Richard Chen
Date:
January 16, 2002 08:51
Subject:
problem using perl debugger with HTTP::Daemon
Message ID:
20020115132801.G8069@pionex.homeland.com
Hello All,

Here is the demo script:

$ cat foo.pl
#!/usr/local/bin/perl
use HTTP::Daemon;
use HTTP::Status;
my $d = HTTP::Daemon->new || die;
print "Please contact me at: <URL:", $d->url, ">\n";
while (my $c = $d->accept) {
    while (my $r = $c->get_request) {
        if ($r->method eq 'GET' ) {
            $c->send_file_response("/etc/hosts");
        } else {
            $c->send_error(RC_FORBIDDEN)
        }
    }
    $c->close;
    undef($c);
}

Here is how I use perl debugger to deal with this:

$ perl -d foo.pl
Loading DB routines from perl5db.pl version 1.0402
Emacs support available.

Enter h or `h h' for help.

main::(bam.pl:4):       my $d = HTTP::Daemon->new || die;
  DB<1> c
Please contact me at: <URL:http://pionex:3519/>

At this point I would like to type 'ctrl-c' and I would expect
be to put in the perl debugger mode.

The problem is that once the statement line
	while (my $c = $d->accept) {
is reached, I cannot type 'ctrl-c' to get into debugger
mode to set breaks and so on.

I found that this problem happens on linux but not on solaris.
For some reason the handling of accept system call seem to
be different on these two platforms. Solaris workes as expected.

I have tried to install a signal hander like this:
	$SIG{INT}='DEFAULT';
but then 'ctrl-c' will make the perl debugger itself quit,
not what I want.

Does anyone know how to make the accept call respond to the
interrupt signal on linux so that the perl debugger work
as expected?

Thanks for any info.

Richard



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About