From 7e52da1b5fba98d75c5ac61615f7ab75910215f9 Mon Sep 17 00:00:00 2001 From: David Inglis Date: Wed, 16 Nov 2005 01:53:51 +0000 Subject: [PATCH] fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=102043 --- .../eclipse/cdt/utils/spawner/Spawner.java | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/Spawner.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/Spawner.java index 888fea89429..df3dc328c8b 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/Spawner.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/Spawner.java @@ -112,6 +112,8 @@ public class Spawner extends Process { * See java.lang.Process#getInputStream (); **/ public InputStream getInputStream() { + if(null == in) + in = new SpawnerInputStream(fChannels[1]); return in; } @@ -119,6 +121,8 @@ public class Spawner extends Process { * See java.lang.Process#getOutputStream (); **/ public OutputStream getOutputStream() { + if(null == out) + out = new SpawnerOutputStream(fChannels[0]); return out; } @@ -126,6 +130,8 @@ public class Spawner extends Process { * See java.lang.Process#getErrorStream (); **/ public InputStream getErrorStream() { + if(null == err) + err = new SpawnerInputStream(fChannels[2]); return err; } @@ -136,12 +142,6 @@ public class Spawner extends Process { while (!isDone) { wait(); } - try { - ((SpawnerInputStream)getErrorStream()).close(); - ((SpawnerInputStream)getInputStream()).close(); - ((SpawnerOutputStream)getOutputStream()).close(); - } catch (IOException e) { - } return status; } @@ -163,9 +163,12 @@ public class Spawner extends Process { terminate(); // Close the streams on this side. try { - ((SpawnerInputStream)getErrorStream()).close(); - ((SpawnerInputStream)getInputStream()).close(); - ((SpawnerOutputStream)getOutputStream()).close(); + if(null == err) + ((SpawnerInputStream)getErrorStream()).close(); + if(null == in) + ((SpawnerInputStream)getInputStream()).close(); + if(null == out) + ((SpawnerOutputStream)getOutputStream()).close(); } catch (IOException e) { } // Grace before using the heavy gone. @@ -229,9 +232,6 @@ public class Spawner extends Process { if (pid == -1) { throw new IOException("Exec error:" + reaper.getErrorMessage()); //$NON-NLS-1$ } - in = new SpawnerInputStream(fChannels[1]); - err = new SpawnerInputStream(fChannels[2]); - out = new SpawnerOutputStream(fChannels[0]); } private void exec_pty(String[] cmdarray, String[] envp, String dirpath, PTY pty) throws IOException { @@ -270,9 +270,6 @@ public class Spawner extends Process { if (pid == -1) { throw new IOException("Exec_tty error:" + reaper.getErrorMessage()); //$NON-NLS-1$ } - in = new SpawnerInputStream(fChannels[1]); - err = new SpawnerInputStream(fChannels[2]); - out = new SpawnerOutputStream(fChannels[0]); } public void exec_detached(String[] cmdarray, String[] envp, String dirpath) throws IOException {