Posted on 2001-06-21
I have a Socket Server program which uses anonymous pipe to execute a command and get the results into a buffer. I followed these steps
Create anonymous pipe, Attach pipe's write end to the STDOUT.
Close write end of the pipe
Read from the pipe's read end
Close the read end of the pipe.
My problem is , every time I read from the pipe the previous output is still there. Say first time I have 100 bytes o/p, second time 30 bytes o/p. But when I read second time still I get 100 bytes (30 new + 70 old) I tried using FlushFileBuffers(), but no imporovements.
Instead of pipe I tried using _popen() function. It works fine, but it only gives me the STDOUT values to the buffer. But I also need the STDERR values if the command execution failed. But in pipes I use two pipes, one for STDOUT another for STDERR.
Could you please help me?
Thanks in advance!