Good morning everyone
Recently, I found myself needing to spawn interactive system processes, where the processes are long-running and interact with the host application via stdin/stdout. I started using the java
ProcessBuilder API, and realized that there were major pitfalls about how the API was supposed to be used.
There is lots of literature on this topic in SO, but I’d like to explain the most important issue: the methods
exitValue in a process are blocking and may not even return if there’s output that hasn’t been consumed by the client (in both stdout and stderr). The consumption of this output has to happen for both stdout and stderr in indendepent threads so that it doesn’t block. These are known as
Read up on some of the pitfalls in this Java World article.
The bottom line is that using java process API correctly requires at least three threads running concurrently and lots of boilerplate. I turned into
scala.sys.process to see if this issue was addressed, and it is.
I think that
scala.sys.process is actually quite nice (though I prefer the aesthetics of the java process API), and I’d like to know what we’re gonna do with it with the upcoming Scala library modularisation. I have a few questions:
- Do we want to add it in the Scala Platform as it is?
- Does anyone know of an Scala or Java alternative?
- In case there’s no alternative and
scala.sys.processis eventually used, would someone want to maintain it?