logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: How to Stop Apache Killing Perl on close Sockets
Author
IanSteigrad



Joined: 13 Sep 2010
Posts: 1
Location: Australia

PostPosted: Mon 13 Sep '10 5:37    Post subject: How to Stop Apache Killing Perl on close Sockets Reply with quote

Hi All,

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

Code:
use CGI qw/:standard/;
print header;
print "<HTML>RETURN TO BROWSER</HTML>";
close STDIN;close STDOUT; close STDERR;
sleep(5);
...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 Perls 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!
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Thu 23 Sep '10 23:29    Post subject: Reply with quote

I'm not into perl, but AFAIK STDIN, STDOUT and STDERR is only available on the command line and not running over apache. Why do you need to close those?
Back to top


Reply to topic   Topic: How to Stop Apache Killing Perl on close Sockets View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner