Am 01.06.2024 um 16:01 schrieb Greg Wooledge:
>> i get the output from ls, but then the thing is hanging indefinitely,
>> apparently not reaching the exit line. :(
> Your first while loop never terminates.  "while read ..." continues
> running until read returns a nonzero exit status, either due to an
> error or EOF.  Your coproc never returns EOF, so the "while read"
> loop just keeps waiting for the next line of output from ls.
> 
> If you're going to communicate with a long-running process that can
> return multiple lines of output per line of input, then you have
> three choices:
> 
>   1) Arrange for some way to communicate how many lines, or bytes,
>      of output are going to be given.
> 
>   2) Send a terminator line (or byte sequence) of some kind that
>      indicates "end of current data set".
> 
>   3) Give up and assume the end of the data set after a certain amount
>      of time has elapsed with no new output arriving.  (This is usually
>      not the best choice.)
> 
> These same design issues occur in any kind of network communication, too.
> Imagine an IMAP client or something, which holds open a network connection
> to its IMAP server.  The client asks for the body of an email message,
> but needs to keep the connection open afterward so that it can ask for
> more things later.  The server has to be able to send the message back
> without closing the connection at the end.  Therefore, the IMAP protocol
> needs some way to "encapsulate" each server response, so the client
> knows when it has received the full message.

WOW!
Just wow, Greg, thank you so much!

After receiving such a wonderful hint/explanation, i did verify it being
correct and got overwhelmed with good feelings, as it allows me to learn
and experiment some more, heading in the direction of possibly solving
my initial problem.

Will share my findings, once i made more progress...

With appreciation, respect, admiration and love.
DdB


Reply via email to