mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-10 02:26:18 +00:00
[FIXED HUDSON-8420] With IBM JDK for example, it seems like there's no
differentiation between Process InputStream&ErrorStream :-(. This means that closing errorStream will actually close every streams.
This commit is contained in:
1 parent
56501b4e33
commit
3c5c2c5cc3
1 file changed
+12
-6
@@ -190,20 +190,26 @@ public abstract class Proc {
|
||||
this.cookie = EnvVars.createCookie();
|
||||
procBuilder.environment().putAll(cookie);
|
||||
this.proc = procBuilder.start();
|
||||
copier = new StreamCopyThread(name+": stdout copier", proc.getInputStream(), out);
|
||||
InputStream procInputStream = proc.getInputStream();
|
||||
copier = new StreamCopyThread(name+": stdout copier", procInputStream, out);
|
||||
copier.start();
|
||||
if(in!=null)
|
||||
new StdinCopyThread(name+": stdin copier",in,proc.getOutputStream()).start();
|
||||
else
|
||||
proc.getOutputStream().close();
|
||||
InputStream procErrorStream = proc.getErrorStream();
|
||||
if(err!=null) {
|
||||
copier2 = new StreamCopyThread(name+": stderr copier", proc.getErrorStream(), err);
|
||||
copier2 = new StreamCopyThread(name+": stderr copier", procErrorStream, err);
|
||||
copier2.start();
|
||||
} else {
|
||||
// while this is not discussed in javadoc, even with ProcessBuilder.redirectErrorStream(true),
|
||||
// Process.getErrorStream() still returns a distinct reader end of a pipe that needs to be closed.
|
||||
// this is according to the source code of JVM
|
||||
proc.getErrorStream().close();
|
||||
// On IBM JDK5, returned input and error streams might be the same.
|
||||
// So, in this case, closing one isn't a good idea since it will close both.
|
||||
if (procErrorStream!=procInputStream) {
|
||||
// while this is not discussed in javadoc, even with ProcessBuilder.redirectErrorStream(true),
|
||||
// Process.getErrorStream() still returns a distinct reader end of a pipe that needs to be closed.
|
||||
// this is according to the source code of HotSpot JVM
|
||||
procErrorStream.close();
|
||||
}
|
||||
copier2 = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user