Weird IPC/Apache issue
Matt Lawrence
matt.lawrence at virgin.net
Tue Jan 19 22:21:21 GMT 2010
Randy J. Ray wrote:
> 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.
>
> (If it helps, I'm using the list-form in open3 to specify the command, not a
> single string since that would invoke an extra bash process.)
>
In my limited experience, running any subprocess in mod_perl is fraught
with difficulty, and it rarely seems to do what you would hope would
work. I've never seen this particular error before, but I'd still
recommend switching to Apache2::SubProcess to do this. It's interface is
broadly similar to IPC::Open3 (at least in one form).
http://perl.apache.org/docs/2.0/api/Apache2/SubProcess.html
Matt
More information about the london.pm
mailing list