Subject: | Apache2::SubProcess Fails to execute script when using example provided from cgi |
Date: | Mon, 27 Apr 2009 16:51:45 +1000 |
To: | bug-mod_perl [...] rt.cpan.org |
From: | Brendan Beveridge <brendan [...] sitesuite.com.au> |
Running the following from a module that gets called from cgi results in
the spawned file being accessed but not executed:
use mod_perl2;
use constant MP2 => ( exists $ENV{MOD_PERL_API_VERSION} and
$ENV{MOD_PERL_API_VERSION} >= 2 );
BEGIN {
if (MP2) {
require Apache2::RequestUtil;
}
}
use Apache2::SubProcess();
my @argv = qw ( foo bar );
my $cmd_file = '/tmp/foo.pl';
my $r = Apache2::RequestUtil->request;
$r->spawn_proc_prog($binary, \@argv);
Contents of /tmp/foo.pl:
#!/usr/bin/perl
use POSIX 'setsid';
chdir '/' or die "Can't chdir to /: $!";
open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
open STDOUT, '+>>', '/tmp/error_log'
or die "Can't write to /dev/null: $!";
open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
setsid or die "Can't start a new session: $!";
`touch /tmp/foo2`;
with this i can see that apache accesses the file but does not seem to
execute it.
however if i comment out use POSIX 'setsid'; and the call to setsid, the
script gets executed.
Now what i have also tried is just adding a use statement for a
completely different module:
use Data::Dumper;
When this is used (with POSIX commented out) it also does not execute
the script.
Any ideas?
Cheers
Brendan
perl version: v5.10.0
mod_perl2 version: 2.0.4-5