You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by John Siracusa <si...@mindspring.com> on 2002/06/30 01:02:13 UTC
IPC::Open2 under mod_perl in Mac OS X
(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
Re: IPC::Open2 under mod_perl in Mac OS X
Posted by Stas Bekman <st...@stason.org>.
John Siracusa wrote:
> On 6/30/02 2:06 AM, Stas Bekman wrote:
>
>>John Siracusa wrote:
>>
>>>(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.
>>
>>It's not a bug in MacOSX, it simply doesn't work with mod_perl.
>
>
> I can't post a direct example now (because I don't have access to the
> machine from here), but I'm pretty sure I do have an example of open2()
> working under mod_perl in Linux--in a perl that is not compiled with sfio.
> That's why I thought it was a Mac OS X bug.
>
> The mod_perl guide talks about the output from system(), exec(), and open(F,
> "| ...") not being sent to the browser, but it doesn't mention open2(). In
> the case of open2(), the input and output is supposed to be tied to
> filehandles that I supply, not connected to mod_perl's (tied?) STDOUT that
> eventually goes to the browser.
>
> So could you clarify why open2() is not expected to work under mod_perl, and
> why it seems to work for me in Linux? (I'll post the working Linux example
> once I can confirm it on Monday.)
I should have said that your example doesn't work on linux with mod_perl
with sfio-enabled perl, since I've tried it and it didn't work. That's
why I've assumed that it's not MacOSX problem.
I really didn't have a chance to investigate why it doesn't work. I've
just tried other alternatives which worked so I've posted them, since I
thought that it was important to you to have a working solution. Feel
free to debug the whole thing and post the details of what exactly
doesn't work and if possible how to fix that.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
Re: IPC::Open2 under mod_perl in Mac OS X
Posted by John Siracusa <si...@mindspring.com>.
On 6/30/02 2:06 AM, Stas Bekman wrote:
> John Siracusa wrote:
>> (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.
>
> It's not a bug in MacOSX, it simply doesn't work with mod_perl.
I can't post a direct example now (because I don't have access to the
machine from here), but I'm pretty sure I do have an example of open2()
working under mod_perl in Linux--in a perl that is not compiled with sfio.
That's why I thought it was a Mac OS X bug.
The mod_perl guide talks about the output from system(), exec(), and open(F,
"| ...") not being sent to the browser, but it doesn't mention open2(). In
the case of open2(), the input and output is supposed to be tied to
filehandles that I supply, not connected to mod_perl's (tied?) STDOUT that
eventually goes to the browser.
So could you clarify why open2() is not expected to work under mod_perl, and
why it seems to work for me in Linux? (I'll post the working Linux example
once I can confirm it on Monday.)
-John
Re: [win32] new perl/apache/mod_perl binary
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Mon, 8 Jul 2002, Gerald Richter wrote:
> Hi Randy,
>
> > I've placed an updated perl-5.6.1/Apache-1.3.26/mod_perl-1.27
> > Win32 binary package, perl-win32-bin-0.8.exe (a self-extracting
> > archive), in ftp://theoryx5.uwinnipeg.ca/pub/other/.
>
> Is this package binary compatible with ActiveState, i.e. can I do a ppm
> install to get additional packages?
>
> Gerald
Hi Gerald,
Yes, it's based on the sources of build 633 of ActiveState.
I've also included the ppm utility for adding packages; some
adjustments in Perl/site/lib/ppm.xml may be needed if Perl is
installed to other than C:/Perl/.
Competely off-topic, but I would like to be able to make up
an msi package of this, so different components could be
installed to desired locations, and a script then run to adjust
accordingly the various config files. I got an add-on to Visual
Studio to make msi packages, but as near as I can tell, you have
to add files one at a time, which is a bit tedious ... Obviously
there's a better way - if anyone's familiar with this, could you
drop me a mine, privately? Thanks.
best regards,
randy
Re: [win32] new perl/apache/mod_perl binary
Posted by Gerald Richter <ri...@ecos.de>.
Hi Randy,
> I've placed an updated perl-5.6.1/Apache-1.3.26/mod_perl-1.27
> Win32 binary package, perl-win32-bin-0.8.exe (a self-extracting
> archive), in ftp://theoryx5.uwinnipeg.ca/pub/other/.
Is this package binary compatible with ActiveState, i.e. can I do a ppm
install to get additional packages?
Gerald
-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925131
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------
Re: [win32] new perl/apache/mod_perl binary
Posted by Gerald Richter <ri...@ecos.de>.
>Yes, the problem is Embperl. Commenting it out (lines 1084 to 1096 of
>httpd.conf) fixed things. Phew.
I have also seen this problem with Embperl when installing Apache service.
It's not special to this binary version.
Since Apache gets always installed correctly, I never had taken the time to
track it down.
Gerald
-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925131
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------
Re: [win32] new perl/apache/mod_perl binary
Posted by Ron Savage <ro...@savage.net.au>.
On Tue, 9 Jul 2002 02:25:41 -0500 (CDT), Randy Kobes wrote:
Randy
>On Tue, 9 Jul 2002, Ron Savage wrote:
>
>>On Mon, 8 Jul 2002 00:24:30 -0500 (CDT), Randy Kobes wrote:
>>>Hi,
>>>I've placed an updated perl-5.6.1/Apache-1.3.26/mod_perl-1.27
>>>Win32 binary package, perl-win32-bin-0.8.exe (a self-extracting
>>>archive), in ftp://theoryx5.uwinnipeg.ca/pub/other/. This
>>
>>I cannot get this to start properly under WinNT.
>>
>>Symptoms:
>>1)
>>shell>Apache.exe -n Apache -k install
>>2 lines of output appear:
>>
>>Installing the Apache service
>>The Apache service has been installed successfully.
>>
>>and then a Windows error box, containing:
>>The instruction at "0x..." referenced memory at "0x...". The memory
>>could not be 'read'.
>>Nevertheless, Apache is installed, and can be uninstalled.
>[ ... ]
>
>Does it start OK, and give the server signature, if you just do
>C:\Apache> Apache.exe
Yes.
>I think the problem might be in Embperl - try commenting out the
>Embperl directives towards the bottom of httpd.conf and see if
>that helps in starting the service. Neverthless, as you say,
>things seem to work OK even with these errors on start-up.
Yes, the problem is Embperl. Commenting it out (lines 1084 to 1096 of
httpd.conf) fixed things. Phew.
Thanx for your help.
--
Cheers
Ron Savage, ron@savage.net.au on 09/07/2002
http://savage.net.au/index.html
Re: [win32] new perl/apache/mod_perl binary
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Tue, 9 Jul 2002, Ron Savage wrote:
> On Mon, 8 Jul 2002 00:24:30 -0500 (CDT), Randy Kobes wrote:
> >Hi,
> >I've placed an updated perl-5.6.1/Apache-1.3.26/mod_perl-1.27
> >Win32 binary package, perl-win32-bin-0.8.exe (a self-extracting
> >archive), in ftp://theoryx5.uwinnipeg.ca/pub/other/. This
>
> I cannot get this to start properly under WinNT.
>
> Symptoms:
> 1)
> shell>Apache.exe -n Apache -k install
> 2 lines of output appear:
>
> Installing the Apache service
> The Apache service has been installed successfully.
>
> and then a Windows error box, containing:
> The instruction at "0x..." referenced memory at "0x...". The memory
> could not be 'read'.
> Nevertheless, Apache is installed, and can be uninstalled.
[ ... ]
Does it start OK, and give the server signature, if you just do
C:\Apache> Apache.exe
I think the problem might be in Embperl - try commenting out the
Embperl directives towards the bottom of httpd.conf and see if
that helps in starting the service. Neverthless, as you say,
things seem to work OK even with these errors on start-up.
best regards,
randy
Re: [win32] new perl/apache/mod_perl binary
Posted by Ron Savage <ro...@savage.net.au>.
On Mon, 8 Jul 2002 00:24:30 -0500 (CDT), Randy Kobes wrote:
>Hi,
>I've placed an updated perl-5.6.1/Apache-1.3.26/mod_perl-1.27
>Win32 binary package, perl-win32-bin-0.8.exe (a self-extracting
>archive), in ftp://theoryx5.uwinnipeg.ca/pub/other/. This
Randy
I cannot get this to start properly under WinNT.
I've tried installing in C:\ and D:\.
I've updated (but not uploaded) my configure-apache.pl to patch these
3 files:
D:\perl\lib\Config.pm
D:\perl\lib\CPAN\Config.pm
D:\apache\conf\httpd.conf
so the install on D:\ should be correct.
Symptoms:
1)
shell>Apache.exe -n Apache -k install
2 lines of output appear:
Installing the Apache service
The Apache service has been installed successfully.
and then a Windows error box, containing:
The instruction at "0x..." referenced memory at "0x...". The memory
could not be 'read'.
Nevertheless, Apache is installed, and can be uninstalled.
2)
If I try
shell>apache -k start
without the install, and try a -k stop in another DOS window, I get
the same error box (in the -k stop window) with _exactly_ the same 2
memory addresses.
Nevertheless, Apache stops.
3) If I try
shell>apache -n Apache -k install
and ignore the error, and then try:
shell>apache -n Apache -k start
I get 2 lines of output:
The Apache service is starting.
The Apache service has started.
with about 6 seconds between the msgs, then straight after the 2nd
msg, the error box with _exactly_ the same 2 memory addresses.
Nevertheless, Apache can be stopped, and it does serve pages.
4) access.log contains the expected.
error.log contains nothing.
ssl_engine_log contains this per start:
-----><8-----
[07/Jul/2002 22:47:15 04016] [info] Server: Apache/1.3.26,
Interface: mod_ssl/2.8.10, Library: OpenSSL/0.9.6d
[07/Jul/2002 22:47:15 04016] [warn] You are using mod_ssl under
Win32. This combination is *NOT* officially supported. Use it at your
own risk!
[07/Jul/2002 22:47:15 04016] [info] Init: 1st startup round (still
not detached)
[07/Jul/2002 22:47:15 04016] [info] Init: Initializing OpenSSL
library
[07/Jul/2002 22:47:15 04016] [info] Init: Loading certificate &
private key of SSL-aware server localhost:443
[07/Jul/2002 22:47:15 04016] [info] Init: Seeding PRNG with 136
bytes of entropy
[07/Jul/2002 22:47:15 04016] [info] Init: Generating temporary RSA
private keys (512/1024 bits)
[07/Jul/2002 22:47:16 04016] [info] Init: Configuring temporary DH
parameters (512/1024 bits)
[07/Jul/2002 22:47:16 04016] [warn] Failed to release global mutex
lock
[07/Jul/2002 22:47:16 04016] [warn] Failed to release global mutex
lock
[07/Jul/2002 22:47:16 04016] [info] Init: Seeding PRNG with 136
bytes of entropy
[07/Jul/2002 22:47:16 04016] [info] Init: Configuring temporary RSA
private keys (512/1024 bits)
[07/Jul/2002 22:47:16 04016] [info] Init: Configuring temporary DH
parameters (512/1024 bits)
[07/Jul/2002 22:47:16 04016] [info] Init: Initializing (virtual)
servers for SSL
[07/Jul/2002 22:47:16 04016] [info] Init: Configuring server
localhost:443 for SSL protocol
[07/Jul/2002 22:47:16 04016] [warn] Init: (localhost:443) RSA server
certificate CommonName (CN) `www.snakeoil.dom' does NOT match server
name!?
[07/Jul/2002 22:47:18 04016] [info] Init: 2nd startup round (already
detached)
[07/Jul/2002 22:47:18 04016] [info] Init: Reinitializing OpenSSL
library
[07/Jul/2002 22:47:18 04016] [warn] Failed to release global mutex
lock
[07/Jul/2002 22:47:18 04016] [warn] Failed to release global mutex
lock
[07/Jul/2002 22:47:18 04016] [info] Init: Seeding PRNG with 136
bytes of entropy
[07/Jul/2002 22:47:19 04016] [info] Init: Configuring temporary RSA
private keys (512/1024 bits)
[07/Jul/2002 22:47:19 04016] [info] Init: Configuring temporary DH
parameters (512/1024 bits)
[07/Jul/2002 22:47:19 04016] [info] Init: Initializing (virtual)
servers for SSL
[07/Jul/2002 22:47:19 04016] [info] Init: Configuring server
localhost:443 for SSL protocol
[07/Jul/2002 22:47:19 04016] [warn] Init: (localhost:443) RSA server
certificate CommonName (CN) `www.snakeoil.dom' does NOT match server
name!?
-----><8-----
--
Cheers
Ron Savage, ron@savage.net.au on 09/07/2002
http://savage.net.au/index.html
Re: [win32] new perl/apache/mod_perl binary
Posted by Ron Savage <ro...@savage.net.au>.
On Mon, 8 Jul 2002 00:24:30 -0500 (CDT), Randy Kobes wrote:
>Hi,
>I've placed an updated perl-5.6.1/Apache-1.3.26/mod_perl-1.27
>Win32 binary package, perl-win32-bin-0.8.exe (a self-extracting
>archive), in ftp://theoryx5.uwinnipeg.ca/pub/other/. This
I've update configure-apache.pl to match. See:
http://savage.net.au/index.html
First timers:
configure-apache.pl simply patches a few Perl and Apache config files
when you install these packages on a drive other than C:. The entire
installation process is documented, including the environment, some
security issues, installing and starting Apache as a service, and
some MS Windows-specific DNS issues.
--
Cheers
Ron Savage, ron@savage.net.au on 10/07/2002
http://savage.net.au/index.html
[win32] new perl/apache/mod_perl binary
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
Hi,
I've placed an updated perl-5.6.1/Apache-1.3.26/mod_perl-1.27
Win32 binary package, perl-win32-bin-0.8.exe (a self-extracting
archive), in ftp://theoryx5.uwinnipeg.ca/pub/other/. This
includes, amongst other things, Embperl, Apache::ASP, and
HTML::Mason, with some simple examples configured in Apache. It
also includes mod_ssl/openssl. Unfortunately, these packages
aren't getting any smaller in size ...
I've removed from the site past versions of these packages,
due to the security issues with earlier versions of Apache
contained in them. Please get in touch with me if you need an
earlier version for some reason.
This will most likely be the last binary package based on
perl-5.6/apache-1.3 - the next one, after perl-5.8 is official,
will be based on perl-5.8 and apache-2/mod_perl-2 (note that
these involve binary incompatablities with lower versions). If
you want a preview of this, grab perl-5.8-win32-bin.tar.gz from
the above ftp directory - I'll be updating this later this week
from cvs.
Please let me know if you have any problems with installation
of either of these.
best regards,
randy kobes
Re: IPC::Open2 under mod_perl in Mac OS X
Posted by Stas Bekman <st...@stason.org>.
John Siracusa wrote:
> (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.
It's not a bug in MacOSX, it simply doesn't work with mod_perl. the
piped program ('upcase' in your example) never sees any input. There are
at least two working alternatives:
1) use IPC::Run:
#!/usr/bin/perl
use strict;
use CGI qw(:standard);
use IPC::Run qw(start finish) ;
local $ENV{PATH};
print header();
my @cmd = qw(/tmp/upcase) ;
my $h = start \@cmd,
'<pipe', \*IN,
'>pipe', \*OUT,
'2>pipe', \*ERR
or die "@cmd returned $?" ;
print IN "Perl::Run and Barrie rule!";
close IN;
print <OUT>, <ERR>;
finish $h ;
the upcase program without any change:
#!/usr/bin/perl
$buf .= $_ while(<STDIN>);
print uc $buf;
2) use Apache::SubProcess:
use Apache::SubProcess ();
my $r = shift;
$r->send_http_header('text/plain');
use vars qw($input);
$input = "Apache::SubProcess rules too!";
my($out, $in, $err) = $r->spawn_child(\&upcase);
print $out $input;
$r->send_fd($in);
sub upcase {
my $r = shift;
$r->subprocess_env(CONTENT_LENGTH => length $input);
$r->filename("/tmp/upcase");
$r->call_exec;
}
notice that the upcase script will be different from yours in this case,
it looks like:
#!/usr/bin/perl
read STDIN, $buf, $ENV{CONTENT_LENGTH};
print uc $buf;
As this module lacks any docs, you can find them here:
http://perl.apache.org/release/docs/1.0/guide/modules.html#Apache__SubProcess
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com