slachiewicz opened a new issue, #1834:
URL: https://github.com/apache/maven-mvnd/issues/1834

   ### Problem
   
   `mvnd-agent` rewrites `ProcessBuilder.start(Redirect[])` so that a child 
started with `Redirect.INHERIT` has its output pumped into the build's 
`System.out`/`System.err` (#241). It only does this when **both** streams 
inherit 
([`Agent.java:30-32`](https://github.com/apache/maven-mvnd/blob/master/agent/src/main/java/org/mvndaemon/mvnd/agent/Agent.java#L30)):
   
   ```java
   if (redirects != null
            && redirects[1] == ProcessBuilder$Redirect.INHERIT
            && redirects[2] == ProcessBuilder$Redirect.INHERIT) {
   ```
   
   A child that inherits only one stream, for example 
`pb.redirectOutput(file).redirectError(INHERIT)`, is left alone, so its 
inherited stream goes to the daemon's own stdout or stderr. That's the daemon 
log, not the client. Under plain `mvn`, the same output reaches the terminal.
   
   ### Proposal
   
   - Switch each `INHERIT` stream to `PIPE` independently and pump only the 
streams that were switched.
   - Name the pump threads and mark them as daemon threads, so that a 
long-running child doesn't keep an unnamed non-daemon thread alive in the 
daemon.
   - Add an integration test next to `ExecOutputTest`: a child that inherits 
only stderr, asserting that its output arrives as a project log message for the 
forking module.
   
   The fix is in the agent and helper only, which are identical on master and 
`mvnd-1.x`, so it can be ported as is.
   
   ### Not in scope
   
   Replacing the agent with native stdio redirection through `mvnd-native` was 
considered and rejected; see 
[#1795](https://github.com/apache/maven-mvnd/issues/1795#issuecomment-6170948865).
 A process-wide fd 1/2 can't attribute output from parallel children to a 
module under `-T`. On Windows, `ProcessImpl` passes the handle cached in 
`FileDescriptor.out`, so `SetStdHandle` has no effect.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to