Given the following setup:
- child process has been opened for reading (for example via
popen()
) - child's
stdout
has been set to line buffered (_IOLBF
) - parent monitors for data on child's
stdout
(select()
,poll()
orepoll()
) - parents reads from child's
stdout
once data available (fgets()
orgetline()
)
Seeing how the stream has been set to line buffered, can we safely assume that there will only ever be one single line to read, or are there possible scenarios where there are multiple lines waiting in the buffer, meaning we have to call fgets()
or getline()
until they hit EOF
(or EAGAIN
/ EWOULDBLOCK
for non-blocking streams)?