5 ActiveState Perl and Apache httpd “couldn’t spawn child process” error

Jan 14th, 2008   11:46 am

If you, like me and many others, use ActiveState Perl to execute Perl CGI scripts on Windows web servers, you might run in to a problem with recent versions of Apache httpd and ActiveState Perl. The latter comes with an installer that makes use with IIS relatively seamless, but using it with httpd requires a tiny bit of tinkering.

With default installs of both (and havng enabled the .cgi Script Handler and using the ExecCGI option in httpd configs), you might find that .cgi files with the (reasonably) standard

#!/usr/bin/perl

shebang/hashbang line won’t work out of the box (as they have for many previous versions of httpd/Perl). The error message in the httpd logs, for me, look like:

[Mon Jan 14 11:01:32 2008] [error] [client 127.0.0.1] (OS 2)The system cannot find the file specified.  : couldn't create child process: 720002: envtest.cgi
[Mon Jan 14 11:01:32 2008] [error] [client 127.0.0.1] (OS 2)The system cannot find the file specified.  : couldn't spawn child process: D:/abc/xyz/web
sites/intranet/envtest.cgi

The quick fix is to add the -w flag to your shebang line, but that involves changing (potentially) many files, and can produce output in the logs that isn’t necessarily severe warnings. Again, you can control the warning levels in the scripts but that, too, involves changing files.

The second workaround is to use the

ScriptInterpreterSource

config (which, in fairness, is documented in the distributed httpd.conf). This tells httpd to use the Windows registry to find out how to execute a given file/script (e.g. .cgi or .pl) and ignore the shebang line. So while this workaround might involve a little more work initially, it does save the need to modify all your CGI/Perl scripts. Here, in brief, is how this workaround is done:

  1. Enable the ScriptInterpreterSource option in your httpd.conf, as documented in the default/distributed example:
    ScriptInterpreterSource registry
  2. Add a registry key to map the .cgi extension to Perl (.pl is already done by the Perl installer). Use regedit.exe to add a Key named “.cgi” to HKEY_LOCAL_MACHINE\SOFTWARE\Classes. In that new key, change the default String (REG_SZ) value to “Perl” (which matches another key that the installer has added). That’s all!
  3. Make sure you have ExecCGI option enabled in your conf files or .htaccess, as normal
  4. Restart Apache

That works for me!

Comments:

William
Jan 14th, 2009   11:39 pm

Hey, that worked out great for me too... Thanks for the tip!!!
Andy
Apr 27th, 2009   4:46 pm

Thanks heaps. That was driving me nuts!
Jim Dawson
Aug 20th, 2009   3:20 pm

I have tried all the above except using the registry. I do not have permission to alter the registry. Instead I change the shebang line. Up until our company migrated to Microsft's "My Place" scheme of things, this worked fine. The only thing I can think of is Apache is running as a user that does not have permission to spawn child processes that execute other programs. I wonder if adding a cgi script handler and renaming the perl exe to some other extension might fool the scheme.
jason guo
Apr 21st, 2010   1:15 pm

There are some differences: XAMPP perl: #!"\xampplite\perl\bin\perl.exe" is good. but below is wrong: #!"\xampplite\perl\bin\perl.exe -w" or #!C:\Perl\bin\perl -w It will shows error:" Server error! The server encountered an internal error and was unable to complete your request. Error message: couldn't create child process: 720002: helloworld.cgi " Also the first char must be #!, if it is space, blank line or ##, it hit error. But in Active Per: #!C:\Perl\bin\perl or #!C:\Perl\bin\perl.exe or #!C:\Perl\bin\perl -w
Thomas Isaksen
Jan 13th, 2017   11:11 am

Gracias! Very nice :)

Leave a Reply

Your email address will not be published. Required fields are marked *

css.php