stuartc has asked for the wisdom of the Perl Monks concerning the following question:
I have a server running perl 5.00503, apache 1.3.19 and mod_perl 1.25 where the code below works perfectly. Then I have my home/dev box which is running perl 5.6.1-26.72.3 and (now) apache 1.3.19/mod_perl 1.25 (configs basically the same except perl) where the same code will not work correctly under mod_perl.
If I run it as a standard cgi or from the shell it works. Under mod_perl the other program just gets a large (infinite?) amount of nothingness (as in $string = <FH> always returns an undef string)
The question is, why? Is it a bug in my code, mod_perl, perl or what? Is there a workaround or some better code to do the same thing?
The code in question:
The test cgi (non mod_perl) code is justpackage Local::JDS::Test; use strict; use Data::Dumper; use Apache::Constants; use IPC::Open2; use Local::JDS::Code; sub handler { my $r = shift; my %hash = call_plugin (); $r->content_type ('text/plain'); $r->send_http_header; $r->print (Dumper (\%hash)); return OK; } sub cgi_handler { my %hash = call_plugin (); print "Content-type: text/plain\n\n"; print Dumper (\%hash); } sub call_plugin { my $command = 'domain_get_expiry'; my %hash = (Domain => 'breadrecipe.com'); #$SIG{'CHLD'} = 'IGNORE'; my $pid = open2 (\*READ, \*WRITE, '/usr/local/apache/htdocs/jds/ba +ckend/plugins/srs_plugin.pl'); my $tmp = select (WRITE); $| = 1; select ($tmp); my $read = \*READ; my $write = \*WRITE; Local::JDS::Code::encode ($write, $command, %hash); my ($ok, %out) = Local::JDS::Code::decode ($read); print $write "QUIT\n\n"; close $write; close $read; return %out; } 1;
Local::JDS::Code just sends and receives text via the specified filehandle.#!/usr/bin/perl -w use strict; use Local::JDS::Test; Local::JDS::Test::cgi_handler ();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is this me or mod_perl?
by trs80 (Priest) on Apr 17, 2002 at 22:24 UTC | |
|
Re: Is this me or mod_perl?
by perrin (Chancellor) on Apr 17, 2002 at 20:41 UTC | |
by stuartc (Initiate) on Apr 17, 2002 at 20:54 UTC | |
by perrin (Chancellor) on Apr 17, 2002 at 21:48 UTC |