Skip to content

Commit

Permalink
Revert "Close subprocess stderr when executing Kernel#system call. El…
Browse files Browse the repository at this point in the history
…iminates "sad" output from spec runs, as well as stty errors when setting up Radiant."

This reverts commit 14f69b6. Reverted
for 1.3 series only.
  • Loading branch information
nicksieger committed Jun 15, 2009
1 parent e76a38a commit 2fd6c3d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 47 deletions.
2 changes: 1 addition & 1 deletion src/org/jruby/RubyKernel.java
Expand Up @@ -1357,7 +1357,7 @@ public static RubyBoolean system(ThreadContext context, IRubyObject recv, IRubyO
Ruby runtime = context.getRuntime(); Ruby runtime = context.getRuntime();
int resultCode; int resultCode;
try { try {
resultCode = ShellLauncher.runAndWaitNoError(runtime, args); resultCode = ShellLauncher.runAndWait(runtime, args);
} catch (Exception e) { } catch (Exception e) {
resultCode = 127; resultCode = 127;
} }
Expand Down
46 changes: 0 additions & 46 deletions src/org/jruby/util/ShellLauncher.java
Expand Up @@ -192,10 +192,6 @@ public static int runAndWait(Ruby runtime, IRubyObject[] rawArgs) {
return runAndWait(runtime, rawArgs, runtime.getOutputStream()); return runAndWait(runtime, rawArgs, runtime.getOutputStream());
} }


public static int runAndWaitNoError(Ruby runtime, IRubyObject[] rawArgs) {
return runAndWaitNoError(runtime, rawArgs, runtime.getOutputStream());
}

public static long runWithoutWait(Ruby runtime, IRubyObject[] rawArgs) { public static long runWithoutWait(Ruby runtime, IRubyObject[] rawArgs) {
return runWithoutWait(runtime, rawArgs, runtime.getOutputStream()); return runWithoutWait(runtime, rawArgs, runtime.getOutputStream());
} }
Expand Down Expand Up @@ -247,19 +243,6 @@ public static int runAndWait(Ruby runtime, IRubyObject[] rawArgs, OutputStream o
} }
} }


public static int runAndWaitNoError(Ruby runtime, IRubyObject[] rawArgs, OutputStream output) {
InputStream input = runtime.getInputStream();
try {
Process aProcess = run(runtime, rawArgs);
handleStreams(aProcess,input,output);
return aProcess.waitFor();
} catch (IOException e) {
throw runtime.newIOErrorFromException(e);
} catch (InterruptedException e) {
throw runtime.newThreadError("unexpected interrupt");
}
}

public static long runWithoutWait(Ruby runtime, IRubyObject[] rawArgs, OutputStream output) { public static long runWithoutWait(Ruby runtime, IRubyObject[] rawArgs, OutputStream output) {
try { try {
POpenProcess aProcess = new POpenProcess(popenShared(runtime, rawArgs), runtime); POpenProcess aProcess = new POpenProcess(popenShared(runtime, rawArgs), runtime);
Expand Down Expand Up @@ -859,35 +842,6 @@ private static void handleStreams(Process p, InputStream in, OutputStream out, O
try { t3.interrupt(); } catch (SecurityException se) {} try { t3.interrupt(); } catch (SecurityException se) {}
} }


private static void handleStreams(Process p, InputStream in, OutputStream out) throws IOException {
InputStream pOut = p.getInputStream();
p.getErrorStream().close();
OutputStream pIn = p.getOutputStream();

StreamPumper t1 = new StreamPumper(pOut, out, false, Pumper.Slave.IN, p);

// The assumption here is that the 'in' stream provides
// proper available() support. If available() always
// returns 0, we'll hang!
StreamPumper t3 = new StreamPumper(in, pIn, true, Pumper.Slave.OUT, p);

t1.start();
t3.start();

try { t1.join(); } catch (InterruptedException ie) {}
t3.quit();

try { out.flush(); } catch (IOException io) {}

try { pIn.close(); } catch (IOException io) {}
try { pOut.close(); } catch (IOException io) {}

// Force t3 to quit, just in case if it's stuck.
// Note: On some platforms, even interrupt might not
// have an effect if the thread is IO blocked.
try { t3.interrupt(); } catch (SecurityException se) {}
}

private static String[] parseCommandLine(ThreadContext context, Ruby runtime, IRubyObject[] rawArgs) { private static String[] parseCommandLine(ThreadContext context, Ruby runtime, IRubyObject[] rawArgs) {
String[] args; String[] args;
if (rawArgs.length == 1) { if (rawArgs.length == 1) {
Expand Down

0 comments on commit 2fd6c3d

Please sign in to comment.