Hi Eitan, I have just used fflush and it works.
The real problem is that C programme was just a test programme. I am
using someone else's programme and I only have the binary! This makes
life complicated. The only way will be to try and unbuffer output and
then launch the c binary so that it inherits the unbuffereing that I
have set.
Thanks very much.
Cheers,
Rob Key
On 14/05/2010 01:36, wizetux wrote:
On May 13, 1:44 pm, li...@eitanadler.com (Eitan Adler) wrote:
The C programme looks like this (very simple)
#include<stdio.h>
int main()
{
int i;
char s[20] = "hello from c";
for (i = 0; i< 15; i++) {
sleep(1);
printf("%s %d\n", s, i);
}
return 0;
}
and yet I only get the output to perl when it is finished and died.
Thanks,
You get multiple levels of output buffering:
1) C does its own output buffering. Take a look at man setvbuf(1)
2) The operating system buffer which is entirely different than the C buffer
You need to disable both of them to get fully unbuffered output
You could also call fflush(stdout); after the printf function.
http://www.thinkage.ca/english/gcos/expl/nsc/lib/fflush.html
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/