I suppose I would do something in this general order:
char big_buffer[BIG_SIZE]; char small_buffer[LINE_SIZE]; unsigned used = 0; big_buffer[0] = '\0';
If you want to get more detailed information, you can allocate space dynamically and try to increase it as necessary in order to keep the volume of the result you output. This will be the best route if you have at least some idea of how much a child can produce.
Edit: given that you are using C ++, the result with dynamic size is actually quite simple:
char line[line_size]; std::string result; while (fgets(line, line_size, your_pipe)) result += line;
source share