Solved

What's the behaviour of CGI?

Posted on 2000-05-05
4
180 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
  • 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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