output not redirected when launching sub-processes on windows?
JRWilding opened this issue · comments
I doubt this is a specific problem to zt-exec, the same behaviour is reproducible when using ProcessBuilder, but just wanted a second opinion as I'm probably doing something wrong.
This outputs the result of the ping to the outputStream:
val pe = ProcessExecutor().apply {
directory(workDirFile)
redirectOutput(outputStream)
command("ping", "-n", "2", "google.com")
}
But if I want to see the console window whilst it is executing the ping, I try to change the command to
command("cmd", "/C", "start", "ping", "-n", "2", "google.com")
The command prompt is shown, I see the results in the window but nothing is written to the stream.
My understanding is that the cmd /c start
launches the ping in a sub-process but it hasn't redirected the output, is it possible to make it redirect?
This issue does not seem to be specific to zt-exec
and I'm not familiar with the behaviour of cmd.exe
in this regard. You might be able to hack something together by redirecting the output to a file and then reading from there. Just an idea.