Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to make server "let-go" of Server-Side-Include Perl script after script sends back html (so script can continue with addl processing) and not hold-up loading of page

Posted on 2000-04-07
9
Medium Priority
?
205 Views
Last Modified: 2013-12-25
Here's my question:

The scenario is as follows:

- Client browser requests an HTML page containing an embedded  
  Server-Side-Include

- The server fetches the page and begins to parse its contents while
  (I assume), sending the parsed contents back to the client browser

- The server encounters the SSI and takes the necessary action

- The action in this case is an instruction to execute a CGI Perl script

- The Perl script is executed and sends back the obligatory
  "Content-type: text/html \n\n" header along with some HTML

*** HERE IS MY PROBLEM ***

- For all intents and purposes, the Perl script is done sending HTML
  back to the Server for inclusion into the page being sent to the
  client browser, BUT, it still has some processing to do.

  ???????? How do I tell the server to "let go" of the CGI Perl script
           (which will still keep running until it is done with
           its processing), and allow the rest of the page to be
           parsed and sent back to the client browser   ?????????

Any information or recommendations would be much appreciated.

Thanks in advance,

Jim Raposa
Webmaster
www.TextEx.net
0
Comment
Question by:m3p
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 10

Expert Comment

by:makerp
ID: 2693543
i dont think that is possible because the way a web server works is to exe the script and then send the resulting stdout back through the socket to the browser .

you could try flushing the stdout in the script once you have finished gerating user output . this will leave the last bit of the script to run but will not detach it from the user.
0
 
LVL 2

Accepted Solution

by:
mattrope earned 600 total points
ID: 2693625
Try forking twice--I think this should create a process which is independent of the original process...  The new process can carry out the necessary processing and the original process can terminate
0
 

Author Comment

by:m3p
ID: 2693689
Thanks for at least trying to answer. I have tried "forking" but the server still ends up waiting for the forked process to finish (I admit maybe I'm not doing the forking correctly), anyway the circumstances in this case make it difficult for me to experiment because my site is hosted on a server that allows CGI but not Telnet, so debugging is difficult. Thanks again for trying.

Jim Raposa
Webmaster
www.TextEx.net
webmaster@TextEx.net
0
RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

 
LVL 2

Expert Comment

by:mattrope
ID: 2693700
Did you fork twice?  I think a double fork is required to make it an independent process...
0
 
LVL 2

Expert Comment

by:mattrope
ID: 2693715
I also just found this on the perlipc manpage. It may also help you...



In some cases (starting server processes, for instance) you'll want to complete dissociate the child process from the parent. The easiest way is to use:


    use POSIX qw(setsid);
    setsid()            or die "Can't start a new session: $!";

However, you may not be on POSIX. The following process is reported to work on most Unixish systems. Non-Unix users should check their Your_OS::Process module for other solutions.

Open /dev/tty and use the TIOCNOTTY ioctl on it. See tty(4) for details.


Change directory to /

Reopen STDIN, STDOUT, and STDERR so they're not connected to the old tty.

Background yourself like this:

    fork && exit;

Ignore hangup signals in case you're running on a shell that doesn't automatically no-hup you:


    $SIG{HUP} = 'IGNORE';       # or whatever you'd like

0
 

Author Comment

by:m3p
ID: 2693808
Regarding the POSIX recommendation, where does the "use" code go and where does the "setsid()" code go, somewhere in the original Perl script after a "fork" perhaps, or in some script that the original attempts to "child off" ??????
0
 

Author Comment

by:m3p
ID: 2693826
Regarding the POSIX recommendation, where does the "use" code go and where does the "setsid()" code go, somewhere in the original Perl script after a "fork" perhaps, or in some script that the original attempts to "child off" ??????
0
 
LVL 2

Expert Comment

by:mattrope
ID: 2693837
I've never tried doing this, but I think that the POSIX method allows you to fork() once and then call the setsid() function from the forked code, thus separating that process from the parent.  The 'use' command can probably go anywhere (generally placed near the top of the program), the setsid() function should be called after you've forked, inside the child process code.  Hope that works!
0
 

Author Comment

by:m3p
ID: 2694623
I've stumbled upon the answer fellas. As it turns out, all that is required is that SSI'd Perl script does a "close (STDOUT)" after having sent back whatever html to the server, thereby causing the server to finally "let go" of the script allowing the page to continue loading and the script to proceed with whatever processing it still needs to do. thanks for all your help guys. if I can ever return the favor, just drop me an email.

Jim Raposa
Webmaster
www.TextEx.net
webmaster@TextEx.net
0

Featured Post

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question