Solved

What's the behaviour of CGI?

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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 …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now