hey! I have a `Process` that gives me both `inputS...
# announcements
l
hey! I have a
Process
that gives me both
inputStream
and
errorStream
(
stdout
and
stderr
respectively), and I need to log the output's of both as soon as they come in. what's the best way to handle that? I guess just doing
inputStream.bufferedReader().forEachLine {...}
would block and thus not allow stderr to be handled, thus blocking the process Any ideas?
s
Use two threads
l
is that the only option? no input-stream combination stuff or something?
s
There is no async io on it so yes.
A crazy workaround would be to use ProcessBuilder redirectTo to two files and read from those async.
Not sure what the problem with two threads are though.
d
NuProcess (github) seems to be an option
Also for fun I wrote a coroutine that polls InputStream::available() and returns a flow. Though this is polling and you release the thread via delay. Not optimal either