logging $! with $r->log_error

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
Mark Copper [ Fr, 10 Dezember 2010 17:59 ] [ ID #2051534 ]

Re: logging $! with $r->log_error

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;
> }
>
> 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=

with $!.

Torsten Förtsch

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

Like fantasy? http://kabatinte.net
torsten.foertsch [ So, 12 Dezember 2010 09:41 ] [ ID #2051542 ]
Webserver » gmane.comp.apache.mod-perl » logging $! with $r->log_error

Vorheriges Thema: mod_perl 2 - %ENV variable
Nächstes Thema: about the message queue server