Membership Membership:
Latest New User Latest: vpros
Past 24 Hours Past 24 Hours: 0
Prev. 24 Hours Prev. 24 Hours: 0
User Count Overall: 137

People Online People Online:
Visitors Visitors: 13
Members Members: 0
Total Total: 13

NakedMCSE Computer Tech Support Forums

So you have passed all of the exams and you are now out in the real world of windows servers, linux servers and freebsd servers faced with a tech support problem you have never seen before...

Find free online tech support in the forums below, respecting that advice is free, but work beyond advice is not...

The General forum is provided for off topic discussion.

You need a user account to post - please Register or Login.

Online Tech Support Forums
  Forum  Open Source Tec...  Apache Server  How to Stop Apache Killing Perl on close Sockets
Previous Previous
Next Next
New Post 9/12/2010 11:26 PM
1 posts
No Ranking

How to Stop Apache Killing Perl on close Sockets 

Hi All,

I'm trying to execute the following code on Apache 2.2 running Perl 5.10 on Windows 32:

use CGI qw/:standard/;
print header;
close STDIN;close STDOUT; close STDERR;
...spool a bunch of emails out to a smtp server...

As you can see, I'm tyrying to return quickly to the client and set the server off running a longer pocess (spooling emails to a smpt server). If I can make this work, i'll get it to update another html page periodically during the process.

The script works fine if I simply execute it from the command line using perl however, when I execute it from apache, the close STDIN;close STDOUT; close STDERR; line causes the Perl script to terminate. I've tried running Apache as admin to see if that helps but the same thing occurs.

It seems that Apache is killing the perl process when I close the socket handles - this occurs even if I use fork() - as soon as the socket handles are closed, the perl.exe terminates, if I dont close the socket handles, then the client browser times out as it waits for the long running process to finish.

I've seen many posts (presumably from unix users) describing how to do this but I can seem to make it work in Windows. I could use a Perl script to write an external perl file and then use Win32::Process to call the perl executable and run the file but if I do that, I have to write all the variables into the temporary perl file which seems a very long-winded way to get my desired outcome.

Any suggestions much appreciated!

Previous Previous
Next Next
  Forum  Open Source Tec...  Apache Server  How to Stop Apache Killing Perl on close Sockets
Send me One Million FREE Guaranteed Visitors