Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1e379ff2290a
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 19e4c3a1f6de
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Feb 24, 2015

  1. Copy the full SHA
    b881f9f View commit details
  2. Copy the full SHA
    e3cf9a9 View commit details
  3. Copy the full SHA
    19e4c3a View commit details
10 changes: 10 additions & 0 deletions core/src/main/java/org/jruby/RubyGlobal.java
Original file line number Diff line number Diff line change
@@ -64,6 +64,8 @@

import static org.jruby.internal.runtime.GlobalVariable.Scope.*;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.Channel;
@@ -283,9 +285,17 @@ private static Channel prepareStdioChannel(Ruby runtime, STDIO stdio, Object str
} else {
switch (stdio) {
case IN:
if (stream instanceof FileInputStream) {
return ((FileInputStream)stream).getChannel();
}

return Channels.newChannel((InputStream)stream);
case OUT:
case ERR:
if (stream instanceof FileOutputStream) {
return ((FileOutputStream)stream).getChannel();
}

return Channels.newChannel((OutputStream)stream);
default: throw new RuntimeException("invalid stdio: " + stdio);
}
14 changes: 14 additions & 0 deletions core/src/main/java/org/jruby/RubyIO.java
Original file line number Diff line number Diff line change
@@ -182,6 +182,12 @@ public static RubyIO prepStdio(Ruby runtime, InputStream f, Channel c, int fmode
RubyIO io = prepIO(runtime, c, fmode | OpenFile.PREP | EncodingUtils.DEFAULT_TEXTMODE, klass, path);

fptr = io.getOpenFileChecked();

// Use standard stdio filenos if we're using System.in et al.
if (f == System.in) {
fptr.fd().realFileno = 0;
}

prepStdioEcflags(fptr, fmode);
fptr.stdio_file = f;

@@ -195,6 +201,14 @@ public static RubyIO prepStdio(Ruby runtime, OutputStream f, Channel c, int fmod
RubyIO io = prepIO(runtime, c, fmode | OpenFile.PREP | EncodingUtils.DEFAULT_TEXTMODE, klass, path);

fptr = io.getOpenFileChecked();

// Use standard stdio filenos if we're using System.in et al.
if (f == System.out) {
fptr.fd().realFileno = 1;
} else if (f == System.err) {
fptr.fd().realFileno = 2;
}

prepStdioEcflags(fptr, fmode);
fptr.stdio_file = f;

10 changes: 7 additions & 3 deletions core/src/main/java/org/jruby/util/ShellLauncher.java
Original file line number Diff line number Diff line change
@@ -866,9 +866,11 @@ public static InputStream unwrapBufferedStream(InputStream filteredStream) {
public static OutputStream unwrapFilterOutputStream(OutputStream filteredStream) {
while (filteredStream instanceof FilterOutputStream) {
try {
filteredStream = (OutputStream)
OutputStream tmpStream = (OutputStream)
FieldAccess.getProtectedFieldValue(FilterOutputStream.class,
"in", filteredStream);
"out", filteredStream);
if (tmpStream == null) break;
filteredStream = tmpStream;
} catch (Exception e) {
break; // break out if we've dug as deep as we can
}
@@ -891,9 +893,11 @@ public static OutputStream unwrapFilterOutputStream(OutputStream filteredStream)
public static InputStream unwrapFilterInputStream(InputStream filteredStream) {
while (filteredStream instanceof FilterInputStream) {
try {
filteredStream = (InputStream)
InputStream tmpStream = (InputStream)
FieldAccess.getProtectedFieldValue(FilterInputStream.class,
"in", filteredStream);
if (tmpStream == null) break;
filteredStream = tmpStream;
} catch (Exception e) {
break; // break out if we've dug as deep as we can
}
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/util/io/PosixShim.java
Original file line number Diff line number Diff line change
@@ -392,8 +392,8 @@ public Channel open(String cwd, String path, ModeFlags flags, int perm) {
}

public Channel open(String cwd, String path, ModeFlags flags, int perm, ClassLoader classLoader) {
if (path.equals("/dev/null") || path.equalsIgnoreCase("nul:") || path.equalsIgnoreCase("nul")) {
return new NullChannel();
if ((path.equals("/dev/null") || path.equalsIgnoreCase("nul")) && Platform.IS_WINDOWS) {
path = "nul:";
}

if (path.startsWith("classpath:/") && classLoader != null) {