in reply to Re^3: Long Process Waits Until End to Display Results
in thread Long Process Waits Until End to Display Results

Have your lengthy process fork off and write its output to a file, then have the CGI refresh every X seconds, reading that output file, and displaying the results.

Currently the lengthy process has its output appended to a cache file which is read by the script every 5 seconds, as outlined in Merlyn's article.

CT

Charles Thomas
Madison, WI
  • Comment on Re^4: Long Process Waits Until End to Display Results

Replies are listed 'Best First'.
Re^5: Long Process Waits Until End to Display Results
by revdiablo (Prior) on Dec 07, 2004 at 19:28 UTC

    So the lengthy process is buffering when writing to the output file? If so, it sounds like the program you're executing is doing the buffering, and I quote sgifford:

    If that's the case, finding an option to cause the program to display output immediately is the easiest solution; the other option is to connect it to a pseudo-tty, with something like Expect.
      It is possible that he did not properly background the forked-off process, and therefore Apache was waiting for all possible output to come back before sending anything. (Apache needs that to be able to include the size of the response in the return headers that it sends to the browser.)

      The fun with buffering is that there are many processes involved, and if any one of them buffers, you won't get your output.

        It is possible that he did not properly background the forked-off process,

        What should I be doing to make sure the process is properly backgrounded?

        CT

        Charles Thomas
        Madison, WI