[sf-perl] Weird IPC/Apache problem

Fred Moyer fred at redhotpenguin.com
Tue Jan 19 17:07:38 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.

There are some apr perlspace libraries that you can safely call
executables from (don't have the api handy), but I'm not surprised
that using ipc based libraries within the context of an https child
may present some issues.  I'd suggest either finding the apr libs that
were made for this or wrapping your binary headers with XS.

>
> Jon
>
> On Jan 19, 2010, at 4:37 PM, Randy J. Ray wrote:
>
>
> (I've posted this to Stackoverflow.com and one other PM list, so apologies if
> anyone happens to see this twice)
>
> I have a module that uses IPC::Open3 (or IPC::Open2, both exhibit this problem)
> to call an external binary (bogofilter in this case) and feed it some input via
> the child-input filehandle, then reads the result from the child-output handle.
> The code works fine when run in most environments. However, the main use of
> this module is in a web service that runs under Apache 2.2.6. And under that
> environment, I get the error:
>
> Cannot fdopen STDOUT: Invalid argument
>
> This only happens when the code runs under Apache. Previously, the code
> constructed a horribly complex command, which included a here-document for the
> input, and ran it with back-ticks. THAT worked, but was very slow and prone to
> breaking in unique and perplexing ways. I would hate to have to revert to the
> old version, but I cannot crack this.
>
> I don't know if it makes a difference, but I'm using the list-form when I call
> open3 ("open3($chld_in, $chld_out, $chld_err, @command_and_args)") rather than
> a string, so as to avoid the extra bash process.
>
> Randy
> --
> """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
> Randy J. Ray      Sunnyvale, CA      http://www.rjray.org   rjray at blackperl.com
>
> Silicon Valley Scale Modelers: http://www.svsm.org
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
>
>
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
>


More information about the SanFrancisco-pm mailing list