Skip to content

Commit 4602aa5

Browse files
author
Donald Hunter
committed
Update openpipe to inherit parent's STDERR on JVM.
This fixes RT #104794. Also updated test eliminate JVM special case.
1 parent 2e5e413 commit 4602aa5

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

src/vm/jvm/runtime/org/perl6/nqp/io/ProcessHandle.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,15 @@
22

33
import java.io.File;
44
import java.io.IOException;
5-
import java.io.InputStream;
6-
import java.io.OutputStream;
7-
import java.nio.ByteBuffer;
8-
import java.nio.channels.ByteChannel;
9-
import java.nio.channels.Channels;
10-
import java.nio.channels.ReadableByteChannel;
11-
import java.nio.channels.WritableByteChannel;
5+
import java.lang.ProcessBuilder.Redirect;
126
import java.nio.charset.Charset;
137
import java.util.Map;
148

159
import org.perl6.nqp.runtime.ExceptionHandling;
1610
import org.perl6.nqp.runtime.ThreadContext;
1711

1812
public class ProcessHandle extends SyncHandle {
19-
13+
2014
Process process;
2115

2216
public ProcessHandle(ThreadContext tc, String cmd, String dir, Map<String, String> env) {
@@ -28,13 +22,13 @@ public ProcessHandle(ThreadContext tc, String cmd, String dir, Map<String, Strin
2822
pb = new ProcessBuilder("sh", "-c", cmd);
2923
}
3024
pb.directory(new File(dir));
31-
pb.redirectErrorStream(true);
25+
pb.redirectError(Redirect.INHERIT);
3226

3327
// Clear the JVM inherited environment and use provided only
3428
Map<String, String> pbEnv = pb.environment();
3529
pbEnv.clear();
3630
pbEnv.putAll(env);
37-
31+
3832
try {
3933
process = pb.start();
4034
chan = new ProcessChannel(process, process.getOutputStream(), process.getInputStream());
@@ -43,7 +37,7 @@ public ProcessHandle(ThreadContext tc, String cmd, String dir, Map<String, Strin
4337
throw ExceptionHandling.dieInternal(tc, e);
4438
}
4539
}
46-
40+
4741
public void flush(ThreadContext tc) {
4842
// Not provided.
4943
}

t/nqp/86-pipes.t

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ plan(14);
1919
ok( nqp::defined($q) == 1, 'nqp::openpipe nonexistent cmd');
2020

2121
my $qstr := nqp::readallfh($q);
22-
nqp::getcomp('nqp').backend.name eq 'moar' ??
23-
ok( $qstr eq '', 'nqp::readallfh with a pipe nonexistent command') !!
2422
nqp::getcomp('nqp').backend.name eq 'parrot' ??
2523
ok( $qstr ~~ / 'doesnotexist' /, 'nqp::readallfh with a pipe nonexistent command') !!
26-
ok( $qstr ~~ / 'not found' | 'not recognized' /, 'nqp::readallfh with a pipe nonexistent command');
24+
ok( $qstr eq '', 'nqp::readallfh with a pipe nonexistent command');
2725

2826
nqp::closefh($q); ok( 1, 'nqp::closefh with a pipe nonexistent command');
2927
}
@@ -43,11 +41,9 @@ plan(14);
4341
ok( nqp::defined($q) == 1, 'nqp::openpipe nonexistent cmd');
4442

4543
my $qstr := nqp::readallfh($q);
46-
nqp::getcomp('nqp').backend.name eq 'moar' ??
47-
ok( $qstr eq '', 'nqp::readallfh with a pipe nonexistent command') !!
4844
nqp::getcomp('nqp').backend.name eq 'parrot' ??
4945
ok( $qstr ~~ / 'doesnotexist' /, 'nqp::readallfh with a pipe nonexistent command') !!
50-
ok( $qstr ~~ / 'not found' | 'not recognized' /, 'nqp::readallfh with a pipe nonexistent command');
46+
ok( $qstr eq '', 'nqp::readallfh with a pipe nonexistent command');
5147

5248
ok( nqp::closefh_i($q) != 0, 'nqp::closefh_i with a pipe nonexistent command');
5349
}

0 commit comments

Comments
 (0)