perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Valdemar Mørch <>
Subject STDIN closed for normal CGI requests after modperl has handled another unrelated URL?
Date Mon, 24 Sep 2007 09:01:10 GMT

We want some URLs handled with modperl and others with regular CGI
handling in one Apache installation, and assume that is possible.

However, once an apache2 process has handled a modperl script, it seems
apache2 doesn't deliver anything on STDIN to other unrelated cgi
subprocesses. This makes POST requests misbehave in our CGI processes as
if there were no form parameters.
has a similar thread, but no solution seemed to be found.

Is there any way to get the apache2 process back-to-normal for regular
CGI handling?

Alternatively, is there any way to get apache to use some processes for
modperl and others for regular CGI so they are kept safely apart?

Otherwise, it seems, that if modperl is used, then apache turns into 
modperl-only. Can that really be true?

Test procedure:

* Create a minimal network install using debian etch.
* Install apache2-mpm-prefork and libapache2-mod-perl2
* Put test.conf (see below) into /etc/apache2/conf.d
* put normal.cgi (see below) into /opt/test
* ln -s /opt/test/normal.cgi /opt/test/mod.cgi
   ( so normal.cgi and mod.cgi "by coincidence" have the same
     implementation. normal.cgi configured to use cgi-script,
     mod.cgi configured to use modperl. See test.conf below. )

# Testcase 1 - all is normal and OK

* /etc/init.d/apache2 restart
* Point browser to http://server/test/normal.cgi
* Hit Submit
* See, that STDIN from the CGI *does* contain
   the submit parameter. (Input is shown as
   {submit=Submit} )

# Testcase 2 - Visit a mod-perl script first and see that STDIN is
                messed up for the CGI. Timing is of the essence
                (I think), so don't wait more than 2-3 seconds between
                browser requests.

* /etc/init.d/apache2 restart
* Point browser to http://server/test/mod.cgi
* Point browser to http://server/test/normal.cgi
* Hit Submit
* See, that STDIN from the CGI *does not* contain
   the submit parameter. (Input is shown as {})

Isn't that a bug? Any workarounds?


Alias /test /opt/test
<Directory /opt/test>
         Options +FollowSymLinks +Indexes
         Options +ExecCGI +MultiViews

<LocationMatch "^/test/mod.cgi$">
                 SetHandler perl-script
                 PerlResponseHandler ModPerl::Registry
                 PerlOptions +ParseHeaders

<LocationMatch "^/test/normal.cgi$">
                 SetHandler cgi-script

normal.cgi / mod.cgi
#!/usr/bin/perl -w
use strict;

my $submit = join("",<>);
my $forest = `ps -U www-data --forest`;
my $perl = (defined $ENV{MOD_PERL}) ? "mod-perl" : "perl";

print <<END;
Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

     <a href="mod.cgi">mod.cgi</a><br>
     <a href="normal.cgi">normal.cgi</a><br><br>
     <form method="post"><input type="submit" name="submit"
Output: {$submit}<br>
PID: $$<br>
Perl: $perl<br>

Peter Valdemar Mørch

View raw message