SPUG: Forking Cgi...
jsouza at cobaltgroup.com
Thu Sep 7 17:02:48 CDT 2000
Hear my tale of woe...
I have a standard html form that sends variables to a cgi. The twist is
that my cgi needs to pass the variables along (after doing a lot of
work) to another cgi somewhere out there in space (on another server).
What I did was to use HTTP::Request, HTTP::Response, and LWP::RobotUA.
Everything worked with my test cgi's, but I noticed that I don't want my
user to have to wait around for my cgi to do it's work, contact the
other cgi, have that cgi do work and return to my cgi so that my cgi
could then respond to the browser.
So I figured I would fork my cgi. The parent process writing out to the
browser "thanks etc..." and the child process to do the work since the
user will never see any of it. This also worked but did not improve
anything. I then tried exec in my child calling a .pl program passing
on the querystring in the args, but this didn't improve anything either.
Ultimately, the users browser hangs until the other process or program
finishes. I am figuring that somehow the Apache server is mainting the
parent process until the child finishes. I tried explictily calling
exit(0) but that didn't kill the parent either.
Is there a way to explicitly end a cgi program and divorce from Apache?
I looked at the zombie process stuff in Advanced Perl/Programming Perl
but I want the Parent to die not-waiting for its children. This would
free the user/browser and have a whole separate non-cgi program running
on the server.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list