On Mon, 14 Aug 2000, Niraj Sheth wrote:
> Hi,
>
> I am having very strange problem with environment variables.
>
> >From Apache::PerlRun script(cgi) I am setting env and firing background
> process ..
> system("$command &") (or print `$command &`;)
>
> now looks like environment variable being persistence b/w different
> requests ONLY in background process. so it's looks to me that mod_perl
> is setting proper "Perl Level" env but failing to reset env at "c level"
> or "process level". I know it's sounds very weird.
> /perl-status?env is printing correctly but my background process
> ($command) is printing few extra env, which i set it in different cgi
> script.
>
> e.g. "script1.pl" is setting $ENV{foo1} = "foo1" and firing print
> `command1 &`;
> and "script2.pl" is setting $ENV{foo2} = "foo2" and firing print
> `command2 &`;
>
> after few hits both env(foo1 and foo2) are visible to both background
> processes.
> while /perl-status?env is displaying correctly.
> Here command1 and command2(perl scripts) are just printing env
>
> Apache/1.3.9 (Unix) mod_perl/1.21
with the test case below, i get the expected results:
env is missing MOD_PERL
all of %ENV should be inherited except for this one. if you have a
small test case that i can drop in and run (small like the one below),
i'll take a look.
my $r = shift;
$r->send_http_header;
local $ENV{PATH} = '/usr/bin';
$ENV{PACKAGE} = __PACKAGE__;
my @env = `env`;
my %env;
for (@env) {
chomp;
my($k,$v) = split '=';
$env{$k} = $v;
}
while (my($k,$v) = each %ENV) {
next if exists $env{$k};
print "env is missing $k\n";
}