[sf-perl] Weird IPC/Apache problem

Randy J. Ray rjray at blackperl.com
Tue Jan 19 13:37:05 PST 2010


(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


More information about the SanFrancisco-pm mailing list