[sf-perl] Weird IPC/Apache problem

Jonathan Swartz swartz at pobox.com
Tue Jan 19 20:19:14 PST 2010

> On Tuesday, January 19, 2010, Jonathan Swartz <swartz at pobox.com>  
> wrote:
>> Could it be because mod_perl 2 closes STDOUT? I just discovered  
>> this and posted about it:
>>    http://marc.info/?l=apache-modperl&m=126296015910250&w=2
>> I think it's a nasty bug, but no one seems to care about it thus  
>> far. Post a follow up on the mod_perl list if your problem is  
>> related.
> I remember seeing your post but I didn't fully understand your
> problem.  Maybe the reason no one cares about it is that it isn't
> affecting them.
> IIRC, modperl ties stdout to $r, so that the output is delivered to
> the web client.

Yah, it's a complicated situation - it took me a few days to  
understand it, and I had to learn things about file descriptors that I  
had previously only vaguely understood. (My understanding is still  
vague, just a little less so.)

It is unrelated mod_perl's tying stdout to $r.

I'll have to write up a better explanation. But suffice to say, under  
mod_perl 2, if I do this:

    my $dbh = DBI->connect( "DBI:mysql:$database", $user, $pass,  
{ RaiseError => 1 } );

and then later do this:

    system('echo "hello"');

then the next use of $dbh will fail. Give it a try! :)

Now you might say "well don't use system() from mod_perl", but  
realistically code such as CPAN modules may do so without your  
knowledge, so it qualifies in my book as a nasty programmer trap.


More information about the SanFrancisco-pm mailing list