The following code:
int z = 0;
while(z < 4)
{
printf("iteration %d\n",z);
sleep(1);
z++;
}
Works fine and stdout buffer is flushed every second if running the program from command line. However, when I try to access the program in a web browser (server – apache on linux, compiled executable (with gcc) handled through cgi), the content is displayed only after 4 seconds and not “step by step”. I am looking for something like PHP’s ob_flush(). And, by the way, is cgi the best way of processing compiled C executables?
Update: neither Works great after disabling fflush(stdout) nor setvbuf(stdout, NULL, _IONBF, 0) is working!!!mod_deflate.
I am not quite sure I understand your question correctly, but in C you can
fflush)Disable buffering (
setbuf,setvbuf)If these won’t work, then either something else is doing buffering or buffering is not the problem.