Follow up on this.
script1.pl(set FOO1 env)
=======
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "PID = $$<BR>\n";
print "SCRIPT1 with FOO1<BR>\n";
#local %ENV = %ENV;
$ENV{FOO1} = "foo1";
print map { "$_ = $ENV{$_}<BR>\n"; } sort keys %ENV;
$command = "dump_env";
print `$command &`; # put it in the background....
-- end
script2.pl(set FOO2 env)
=======
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "PID = $$<BR>\n";
print "SCRIPT1 with FOO2<BR>\n";
#local %ENV = %ENV;
$ENV{FOO2} = "foo2";
print map { "$_ = $ENV{$_}<BR>\n"; } sort keys %ENV;
$command = "dump_env";
print `$command &`; # put it in the background....
-- end
dump_env
=======
#!/usr/local/bin/perl
print "$0 @ARGV\n";
print map { "$0 $_ = $ENV{$_}<BR>\n"; } sort keys %ENV;
--end
running "httpd -X" i will get FOO1 and FOO2 both from the print
statement of dum_env.
while script1.pl is ONLY printing FOO1 which is correct as well as
script2.pl is ONLY printing FOO2 which is also correct.
so why dump_env is getting both?
If I either uncomment "local %ENV = %ENV;" in script or put "%ENV = ();"
in PerlCleanupHandler then dump_env is working fine.
I tried both Apache::PerlRun and Apache::Registry which same result.
I would appreciate any help.
-Niraj
> -----Original Message-----
> From: Niraj Sheth [mailto:[EMAIL PROTECTED]]
> Sent: Monday, August 14, 2000 12:10 PM
> To: [EMAIL PROTECTED]
> Subject: env in background process
>
>
> 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
> Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
> Platform:
> osname=solaris, osvers=2.6, archname=sun4-solaris
> uname='sunos nlsun268 5.6 generic_105181-14 sun4u sparc
> sunw,ultra-4
> '
> hint=recommended, useposix=true, d_sigaction=define
> usethreads=undef useperlio=undef d_sfio=undef
> Compiler:
> cc='gcc', optimize='-O', gccversion=2.8.1
> cppflags='-I/usr/local/include'
> ccflags ='-I/usr/local/include'
> stdchar='unsigned char', d_stdstdio=define, usevfork=false
> intsize=4, longsize=4, ptrsize=4, doublesize=8
> d_longlong=define, longlongsize=8, d_longdbl=define,
> longdblsize=16
> alignbytes=8, usemymalloc=y, prototype=define
> Linker and Libraries:
> ld='gcc', ldflags =' -L/usr/local/lib'
> libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
> libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
> libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
> Dynamic Linking:
> dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
> cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'
>
>
> Any comments?
>
> Thanks,
> Niraj
>