in reply to Re: cgi environment using mod_perl
in thread cgi environment using mod_perl

That's only the case with mod_perl 2. In mod_perl 1, Apache::Registry does the chdir automatically.

Replies are listed 'Best First'.
Re^2: cgi environment using mod_perl
by Coruscate (Sexton) on Jan 21, 2004 at 22:03 UTC

    I'll remember that in case I ever have to suffer the long journey of porting anything from mod_perl 1.x to mod_perl 1.9x/2.x. That would certainly be a strange thing to see happen if you're not expecting it. :)

      There's a documented workaround for it if you're using prefork. The problem is that chdir is not safe when using threads.

        I really didn't want to hear that. I haven't experienced any problems with this (yet), but what might I expect to happen? Or am I safe because it's within a BEGIN {} block? I could see it causing problems in the middle of the script, but if it's a one-time switch before anything else happens?

        C:\>Apache -V Server version: Apache/2.0.48 [snip] Architecture: 32-bit Server compiled with.... -D APACHE_MPM_DIR="server/mpm/winnt" [snip] C:\>perl -V Summary of my perl5 (revision 5 version 8 subversion 2) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread [snip] usethreads=undef use5005threads=undef useithreads=define usemultip +licity=def ine [snip] Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL +_IMPLICIT_ CONTEXT PERL_IMPLICIT_SYS [snip] C:\> more c:\apache2\conf\httpd.conf [snip] # WinNT MPM # ThreadsPerChild: constant number of worker threads in the server pro +cess # MaxRequestsPerChild: maximum number of requests a server process se +rves <IfModule mpm_winnt.c> ThreadsPerChild 100 MaxRequestsPerChild 0 </IfModule> [snip] LoadFile "C:/Perl/bin/perl58.dll" LoadModule perl_module modules/mod_perl.so [snip] C:\> more c:\apache2\www\port80\test.pl #!c:/perl/bin/perl -w $|++; BEGIN { chdir "C:/Apache2/www/port80" } use strict; use CGI::Simple; [snip]