Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically pump streams with os.Inherit on changed System.out System.err System.in #282

Closed
lolgab opened this issue Jun 26, 2024 · 0 comments · Fixed by #283
Closed
Milestone

Comments

@lolgab
Copy link
Member

lolgab commented Jun 26, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants