>  -------Original Message-------
>  From: srinivasa kartheek
>  
> My question at the end of the meeting was why the counter is not getting
>  printed every five seconds even if we didn't send any signal.
>  It turns out the reason is because the console stdout is buffered and
>  if I flush explicitly the behaviour is as I expected.
>  
>  
>  for (int i = 0; ; i++) {
>  
>  printf ("%d ", i);
>  
>  fflush(stdout);
>  
>  sleep(duration);
>  }
>  return 0;
>  }
>  

This is an artifact of how 'stream' library functions relate to actual i/o.

Please see
https://stackoverflow.com/questions/19365655/disable-buffering-for-stdin-and-stdout-using-setvbuf

warm regards
Saifi.

Reply via email to