Re: FastCGI, Perl5, Environment variables and timezones

Jan Drehmer (Jan.X.Drehmer@telia.se)
Fri, 21 Feb 1997 10:59:13 +0100

Message-Id: <199702210959.KAA05926@linkoping.trab.se>
To: fastcgi-developers@OpenMarket.com
Subject: Re: FastCGI, Perl5, Environment variables and timezones 
In-Reply-To: Your message of "Thu, 20 Feb 1997 09:45:48 +0100."
             <199702200845.JAA23163@linkoping.trab.se> 
Date: Fri, 21 Feb 1997 10:59:13 +0100
From: Jan Drehmer <Jan.X.Drehmer@telia.se>


Hi again, I will answer my own question about Perl5, FastCGI and weird
behaviour of environment variables.

My problem:
  In the second all following calls of FCGI::accept calls to localtime()
  did not honor the TZ environment variable and further checks showed that
  backtick commands didn't get *any* env variables at all.

  I used the cgi-fcgi program to connect to the FCGI scripts due to the
  fact that I use Netscape servers and haven't had the time to port the
  Apache mod_fastcgi module to NSAPI.

A solution:
  It seems that FCGI.pm does something with the %ENV hash list and the 
  perl5 interpreter doesn't really get this. In the FCGI::accept loop
  the %ENV hash list contains valid values but internal perl5 functions
  doesn't know about these values.
  This is how I fixed this: (very simple code)

  while (FCGI::accept() >= 0) {

     # Do this the very first thing in the loop
     my $key;
     foreach $key (keys %ENV) {
        $ENV{$key} = $ENV{$key};
     }

     # ... Do what the script should do ...
  }

  This makes the perl5 interpreter 'know' about the ENV values again
  and the program will function as you would think it should do.


I hope this can help others that have experienced or will experience this
problem.

/Jan Drehmer, Telia Engineering AB, Linkoping, Sweden
Jan.X.Drehmer@telia.se