On Sunday 01 October 2006 15: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. > > anyway the interesting part is in the while loop the rest is just formatting. > > while (1) > { > // read(fd,buf,50); > printf("hello world\n"); > } > > it prints out real fast to screen (as you would expect) and it can be > piped to a file ./a.out > test.txt resulting in a large text file (as you > would expect) > > > 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.
Use strace to find out what is going on. Does it work if you do write(1, "foo bar\n", 8) instead of printf? -- vda