On 01 October 2006 14:34, Owen Lucas wrote:

> Im doing a program that reads in stuff from the serial port under linux.
> Once read in there is a bit of formatting and it then needs to get piped
> to something else. At the end is the cut down code.

  This is a question for the gcc-help list, not the main gcc list, which is
about programming the internals of the compiler itself.  Please send
follow-ups there.

>   while (1)
>     {
>      // read(fd,buf,50);
>       printf("hello world\n");
>     }

> now if the read(fd,buf,50); line is uncommented, it now only does
> printf("hello world\n") everytime a CR is reciveded on the serial port
> which terminates the read function (as it should). Now it displays to
> screen (as it should) but it does NOT pipe to file with ./a.out >
> test.txt. It creates a blank file but doesnt put anything in it. Why does
> a read function unrelated to STDIN or STDOUT in the code muck up a linux
> pipe?????? Got be baffled and dont know what to do now.

  Something's gone funny with the stdout buffering.  Maybe related to ICANON.
Try adding a fflush (stdout) after the printf.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....

Reply via email to