Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^4: cgi environment using mod_perl

by Coruscate (Sexton)
on Jan 21, 2004 at 22:51 UTC ( [id://323052]=note: print w/replies, xml ) Need Help??


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

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]

Replies are listed 'Best First'.
Re: Re^4: cgi environment using mod_perl
by perrin (Chancellor) on Jan 21, 2004 at 23:24 UTC
    Basically, the issue is that chdir changes the current working directory, but that is global to the process, not to a thread. The result is that if anything else does a chdir, you will no longer be in the directory you thought you were in.

    For the most part, as long as all of your scripts chdir to the same place you should be okay. You can probably assume that Apache 2 and mod_perl 2 will not do any chdir stuff, but other CPAN modules might. Best to test with high currency and see what happens, as well as grep'ing any modules you use for chdir.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://323052]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-23 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found