guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: capture stdout and stderr


From: Thomas Danckaert
Subject: Re: capture stdout and stderr
Date: Sat, 26 May 2018 13:40:41 +0200 (CEST)

From: Catonano <address@hidden>
Subject: Re: capture stdout and stderr
Date: Sat, 26 May 2018 12:24:11 +0200

The first observation is that in the first case, you close the port cotaining
the error _prior_ to attempting reading from the port

In the second case, you attempt reading from the port AND THEN you close the
port

Yes, I also found that a bit surprising when I wrote that. However, with a string-port, you have to call get-output-string *before* closing the port, so that's why it's written like that (https://www.gnu.org/software/guile/manual/html_node/String-Ports.html).

I undertsand that the writing on ports is mediated by some form of buffering, or something, and closing the port also "flushes" the port, meaning that if
there are some remnants to be written yet, they get written

I don't even know of with-error-to-port automatically closes the port so that
manually closing it shouldn't be necessary

My reason to close the port was in order to have an EOF at the end of the error output, so I can simply use get-string-all to retrieve it. But yes, otherwise buffering might also come into play. I think I checked that with-error-to-port didn't close the port for me. I'm now leaving on a short vacation, so don't have time to check again in more detail, but it's a good suggestion.

Thanks!

Thomas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]