UNIX/Linux IPC : Reading from a pipe. How to know length of data at runtime?
问题 I have a child process which generates some output of variable length and then sends it to the parent using a half duplex pipe. In the parent, how do I use the read() function? Since the data can be of different length each time, how can I at run time know the size of the data to do any malloc() for a buffer? Can the fstat() function be used on a pipe file descriptor? I know that the read() function will read a specified number of bytes but will return 0 if the end of file (not the EOF