[Openmcl-devel] timely output from an external-process-output-stream

Diedrich Wolter dwolter at informatik.uni-bremen.de
Wed Mar 23 10:03:27 PDT 2011


Hi,

the 'delay' occurs most likely since the output stream is not flushed.  
Just add the line fflush(stdout) to your C-program and your done. To  
the best of my knowledge, flushing behavior solely depends on the  
output device you write to and there's no programmatic way to change  
this (terminal devices tend to flush after \n, pipes generally don't).

> #include <stdio.h>
> int main () {
>  int i;
>  for (i=0; i<5; i++) {
>    printf("line %i\n", i);
---> fflush(stdout); <---

>    sleep(1);
>  }
>  return 0;
> }


Best,
   Diedrich

--
Diedrich Wolter
dwolter at informatik.uni-bremen.de
SFB/TR 8 Spatial Cognition, project R3-[Q-Shape]




More information about the Openmcl-devel mailing list