template<class Callback>
class folly::Subprocess::ReadLinesCallback< Callback >
A readCallback for Subprocess::communicate() that helps you consume lines (or other delimited pieces) from your subprocess's file descriptors. Use the readLinesCallback() helper to get template deduction. For example:
subprocess.communicate( Subprocess::readLinesCallback( [](int fd, folly::StringPiece s) { std::cout << fd << " said: " << s; return false; // Keep reading from the child } ), [](int pdf, int cfd){ return true; } // Don't write to the child );
If a file line exceeds maxLineLength, your callback will get some initial chunks of maxLineLength with no trailing delimiters. The final chunk of a line is delimiter-terminated iff the delimiter was present in the input. In particular, the last line in a file always lacks a delimiter – so if a file ends on a delimiter, the final line is empty.
Like a regular communicate() callback, your fdLineCb() normally returns false. It may return true to tell Subprocess to close the underlying file descriptor. The child process may then receive SIGPIPE or get EPIPE errors on writes.
Definition at line 749 of file Subprocess.h.