In Mill server-client mode the standard streams are changed using System.setOut, etc. methods so they can be propagated from the server to the client and shown to the user's console.
Unfortunately, when running processes with os.proc and os.Inherit the changes done with System.setOut, etc. are not honored, since the java.lang.ProcessBuilder doesn't honor the changes in System streams.
This issue is about natively support honoring the changes in streams in os.proc without users having to manually redirect the output and the input via pipes.
Since there is no way to know if the streams were changed, os-lib would need to add an API to allow users to set the original streams, like:
os.proc.setOriginalSystemOut(System.out)
os.proc.setOriginalSystemErr(System.err)
os.proc.setOriginalSystemIn(System.in)
// or
os.proc.setOriginalStreams()
// which would do the same things but on the background
So when a process is executed and System.in ne os.proc.originalSystemIn && stdin == os.Inherit it would pump the data to the System.in using os.Pipe (as we currently do in Mill), since it assumes it is not the original System.in.
The same thing would happen with System.out and System.err.
To work around this problem, Mill implemented some helper methods, but they are bespoke and are not what users would want to write.
In fact, many plugins and users' builds in the wild just use os.proc with os.Inherit since it's the easiest way, and then they see broken output in server-client mode.
In Mill server-client mode the standard streams are changed using
System.setOut
, etc. methods so they can be propagated from the server to the client and shown to the user's console. Unfortunately, when running processes withos.proc
andos.Inherit
the changes done withSystem.setOut
, etc. are not honored, since thejava.lang.ProcessBuilder
doesn't honor the changes in System streams. This issue is about natively support honoring the changes in streams inos.proc
without users having to manually redirect the output and the input via pipes. Since there is no way to know if the streams were changed, os-lib would need to add an API to allow users to set the original streams, like:So when a process is executed and
System.in ne os.proc.originalSystemIn && stdin == os.Inherit
it would pump the data to theSystem.in
usingos.Pipe
(as we currently do in Mill), since it assumes it is not the originalSystem.in
. The same thing would happen withSystem.out
andSystem.err
.To work around this problem, Mill implemented some helper methods, but they are bespoke and are not what users would want to write. In fact, many plugins and users' builds in the wild just use
os.proc
withos.Inherit
since it's the easiest way, and then they see broken output in server-client mode.