Solved

What's the behaviour of CGI?

Posted on 2000-05-05
4
184 Views
Last Modified: 2013-12-25
I would like to write a CGI program in C that response to the request immediately and then continue to do another job in the same CGI. However, the browser receive the response only after all the jobs have been done in the CGI.

How can I get the response immediately and the CGI keeps running on other tasks?

Many thanks!
0
Comment
Question by:andersy
[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
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
makerp earned 150 total points
ID: 2780204
basically this was covered by the question below.

http://www.experts-exchange.com/jsp/qShow.jsp?ta=cgi&qid=10324508 

what you need to do is create a new process by doing a fork or new thread in win32 and then close the stdout. the response will then be ended and the other process(es) will continue to run.
0
 

Author Comment

by:andersy
ID: 2783240
You mean to use
  fclose(stdout)

But How can I print to stdout if I want to print other info to the page after the process is done in the other thread?

Can I reopen the stdout and how?

many thanks.
0
 
LVL 10

Expert Comment

by:makerp
ID: 2787632
by the sound of it then you dont want to close the stdout but just flush it. so

do some proccessing

flush stdout

do your extra bit

flush and close stdout

now what should happern is the page should load at the user end but the page should have that little status bit at the bottom doing something while it waits for the rest of the page.

you might have to close the stdout and then re-open it if your cannt flush it. i know you can flush streams in C but im not sure about perl
0
 

Author Comment

by:andersy
ID: 2791635
I've tried to flush the stdout, but it won't work. It works only if I close the stdout.

Thanks anyway!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to count occurrences of each item in an array.
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…

734 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