logging $! with $r->log_error

logging $! with $r->log_error

am 10.12.2010 17:59:23 von Mark Copper

Hi all,

I stole this snippet years ago (and probably modified it improperly)
only to learn yesterday it has a serious problem:

unless(open MAIL, "| /usr/sbin/sendmail -t -i -F'...' -f'...''"){
$main::r->log_error("Couldn't open mail: $!");
return DECLINED;
}

namely this error:
[Thu Dec 09 16:32:44 2010] [error] [client ...] Can't call method
"log_error" on an undefined value at ...

resulting in a 500 HTTP response (which I want very much to avoid).

I can just remove the offending "$!", of course, but is then I won't
get the error message when it *does* get set.

So my question: when "open" to a pipe does not return a process PID
and $! is not set, is there any other source of information regarding
what caused the error?

I'm pretty ignorant on this type of thing, so sorry if it's a stupid question.

Mark

Re: logging $! with $r->log_error

am 12.12.2010 09:41:56 von torsten.foertsch

On Friday, December 10, 2010 17:59:23 Mark Copper wrote:
> unless(open MAIL, "| /usr/sbin/sendmail -t -i -F'...' -f'...''"){
> $main::r->log_error("Couldn't open mail: $!");
> return DECLINED;
> }
>=20
> namely this error:
> [Thu Dec 09 16:32:44 2010] [error] [client ...] Can't call method
> "log_error" on an undefined value at ...

$main::r is not defined here. That is what the message says. Nothing to do=
=20
with $!.

Torsten Förtsch

=2D-=20
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net