Re: stdout from scripts goes to apache logs

Ed Sabol <[email protected]> Tue, 14 May 2024 00:18:22 -0400
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
On May 13, 2024, at 11:00 PM, Steven Haigh via modperl <[email protected]> wrote:
> If I was to guess, it seems like an interaction with open3 and modperl.
> 
> https://perldoc.perl.org/IPC::Open3

Yes, this is a known problem with IPC::Open3 that is commonly seen with mod_perl. It's been a Perl bug since 2009, and nobody has apparently been interested in fixing it. :(

https://github.com/Perl/perl5/issues/9759

So I think you just need to work around it. I recommend not using IPC::Open3 in any mod_perl projects. I typically just use backticks and redirect stderr to stdout or to a temp file, but sometimes you just need separate filehandles. For that, I offer the following potential workarounds that you can try:

(1) Use IPC::Run instead of IPC::Open3. I've seen at least one report that says that IPC::Run works well in mod_perl, and it can do similar things.

https://metacpan.org/pod/IPC::Run

(2) Re-jigger the file descriptors as shown here:

https://stackoverflow.com/questions/2097247/ipcopen3-fails-running-under-apache/24311232#24311232

Hope this helps,
Ed