You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Mi...@gad.de on 2001/11/14 17:30:51 UTC
Apache::PerlRun und Prototypes
Hi,
I just found that one of our Perl scripts used CORE::exit, I changed that
and found a whole bunch of problems. The biggest one is, that
Apache::PerlRun doesn't seem to like prototypes. It runs the script some
times but will eventually fail with
[Wed Nov 14 17:05:00 2001] [error] PerlRun: `[Wed Nov 14 17:05:00 2001] Subs.pl: [Wed Nov 14 17:05:00 2001] Subs.pl: Not a CODE reference at
/opt/y/cgi-bin/Sources/MJTools.pl line 110.
[Wed Nov 14 17:05:00 2001] Subs.pl: Compilation failed in require.
'
MJTools.pl:110 is "fclose(F);"
Subs.pl is "sub fclose ($) {"
I removed all prototypes and this problem was gone. Oh, BTW: The mentioned files and line number doesn't always relate to the problem.
Another point was this construct:
use subs 'exit';
sub exit {
[...]
CORE::exit( $_[0] || 0 );
}
eval {
&main; # uses exit() at about 100 places
};
if ($@) {
&fatal_error("Untrapped Error:<BR> $@");
}
I'm still not sure how to change that "The Right Way" to work with mod_perl, but the following works. Maxbe someone has a better idea?
use subs 'exit';
sub exit {
[...]
Apache::exit(0); # 0=OK, -2=DONE
}
eval {
&main;
};
if ($@ =~ /^\S+at /s) {
&fatal_error("Untrapped Error:<BR> $@");
}
Apache::exit(0);
Yes, both Apache::exits are needed. If I leave the first one a CORE::exit, the child really exits, if I leave out the second, it would 500...
Michael