Hi. I am using the fork() and pipe() functions to establish communication between 2 processes. If one process writes to the pipe, and the second process reads the pipe, how does the second process clear the input that it read on the last read operation? (Or alternatively, how can I make process 1 clear the pipe before it writes to it?)
For example, process 1 writes data as follows:
string1
string2
string3
Process 2 is waiting for the data that process 1 is writing. In a loop, as process 2 reads the pipe, this is what gets read as a string on each iteration:
1. string1
2. string1string2
3. string1string2string3
How do I clear the pipe in process 2 after each read so that I only get the latest string written by process 1? Just to clarify, I want process 2 to read the the data from process 1 in this manner:
1. string1
2. string2
3. string3
Thanks!



LinkBack URL
About LinkBacks


