Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
libsubprocess: rename/cleanup read_eof_reached() add flux_subprocess_read_until_eof() #2265
This PR does two things (it could be split into two PRs, but keeping it as one given #2255 thought process).
After a lot of thought on how to 1) make it easier to deal with EOF scenarios with read streams and 2) how to make it easier / more convenient for callers, in this PR:
The overall approach seems good, however I wonder if we could shorten some of the function names.
What if we renamed
Just curious, what does
I wonder if re-naming should be tied into the function signature discussion in #2253, since its also "read_line" and "read_trimmed_line" in the buffer lib. Perhaps
Good question, it returns > 0 when EOF/closed has been noticed. Number of bytes left to be read doesn't matter. I should probably add something to the header comments about that.
@@ Coverage Diff @@ ## master #2265 +/- ## ========================================== - Coverage 80.81% 80.78% -0.04% ========================================== Files 213 210 -3 Lines 33412 33239 -173 ========================================== - Hits 27002 26851 -151 + Misses 6410 6388 -22
Update flux_subprocess_read_line() with additional information on newline existing in buffer.
Rename flux_subprocess_read_eof_reached() to flux_subprocess_read_stream_closed(). Add additional header information on function usage.
Add a flag to struct subprocess_channel, indicating if the read buffer in the struct is line buffered.
Fix a line buffering corner case with remote subprocesses. If the last line of remote output is not terminated by a newline, the output callback (e.g. on_stdout) can be called multiple times until EOF is received.