(I'm not sure if this is a mod_perl thing of a Mac OS X bug, so I'm posting
it to both lists. Redirect follow-ups as appropriate.)
open2() doesn't seem to work for me when running under mod_perl in Mac OS X.
Here's the test case:
In /usr/local/bin/upcase
#!/usr/bin/perl
$buf .= $_ while(<STDIN>);
print uc $buf;
Example usage from the command line:
% echo hello | upcase
HELLO
Now here's the CGI script that uses open2() to talk to the upcase program:
#!/usr/bin/perl
use strict;
use CGI qw(:standard);
use IPC::Open2;
open2(\*READ, \*WRITE, '/usr/local/bin/upcase');
print WRITE "Hello";
close(WRITE);
my $res;
$res .= $_ while(<READ>);
close(READ);
print header(), "Got: $res"
Running it under plain CGI shows the expected output:
Got: HELLO
But running it under Apache::PerlRun or Apache::Registry shows:
Got:
Any ideas? (Some more verbose configuration information is included below.)
-John
% perl -V
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=darwin, osvers=1.4, archname=darwin
uname='darwin localhost 1.4 darwin kernel version 1.4: sun sep 9
15:39:59 pdt 2001; root:xnuxnu-201.obj~1release_ppc power macintosh powerpc
'
config_args='-des -Dfirstmakefile=GNUmakefile -Dldflags=-flat_namespace'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
Compiler:
cc='cc', ccflags ='-pipe -fno-common -DHAS_TELLDIR_PROTOTYPE
-fno-strict-aliasing -I/usr/local/include',
optimize='-O3',
cppflags='-pipe -fno-common -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing
-I/usr/local/include'
ccversion='', gccversion='Apple devkit-based CPP 6.0', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags ='-flat_namespace -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib
libs=-lm -lc
perllibs=-lm -lc
libc=/System/Library/Frameworks/System.framework/System, so=dylib,
useshrplib=true, libperl=libperl.dylib
Dynamic Linking:
dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-flat_namespace -bundle -undefined suppress
-L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under darwin
Compiled at 01/26/02 17:02:40
%ENV:
PERL_READLINE_NOWARN=""
@INC:
/System/Library/Perl/darwin
/System/Library/Perl
/Library/Perl/darwin
/Library/Perl
/Library/Perl
/Network/Library/Perl/darwin
/Network/Library/Perl
/Network/Library/Perl
.
% uname -a
Darwin xxx.com 5.5 Darwin Kernel Version 5.5: Thu May 30 14:51:26 PDT 2002;
root:xnu/xnu-201.42.3.obj~1/RELEASE_PPC Power Macintosh powerpc
Apache/1.3.23 (Darwin) mod_perl/1.26
(I've also tried this with apache 1.3.26 and got the same results)
% httpd -V
Server version: Apache/1.3.23 (Darwin)
Server built: 02/16/02 15:51:05
Server's Module Magic Number: 19990320:11
Server compiled with....
-D HAVE_MMAP
-D USE_MMAP_SCOREBOARD
-D USE_MMAP_FILES
-D HAVE_FCNTL_SERIALIZED_ACCEPT
-D HAVE_FLOCK_SERIALIZED_ACCEPT
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D HTTPD_ROOT="/usr/local/apache"
-D SUEXEC_BIN="/usr/local/apache/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/httpd.scoreboard"
-D DEFAULT_LOCKFILE="logs/httpd.lock"
-D DEFAULT_XFERLOG="logs/access_log"
-D DEFAULT_ERRORLOG="logs/error_log"
-D TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
-D ACCESS_CONFIG_FILE="conf/access.conf"
-D RESOURCE_CONFIG_FILE="conf/srm.conf"
% httpd -l
Compiled-in modules:
http_core.c
mod_env.c
mod_log_config.c
mod_mime.c
mod_negotiation.c
mod_status.c
mod_include.c
mod_autoindex.c
mod_dir.c
mod_cgi.c
mod_asis.c
mod_imap.c
mod_actions.c
mod_userdir.c
mod_alias.c
mod_access.c
mod_auth.c
mod_setenvif.c
mod_perl.c
suexec: disabled; invalid wrapper /usr/local/apache/bin/suexec