From 5cbfee467ccc80bbff7b8bc35c0a150e3be5c9da Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 22 Oct 2010 14:39:38 -0600 Subject: [PATCH] fix Runtime.exec on Posix Due to a silly cut-and-paste error, we were incorrectly passing the stdout and stderr file descriptors back from native code to Java, which prevented reading the output of the child process. --- classpath/java-lang.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/classpath/java-lang.cpp b/classpath/java-lang.cpp index 8303e3e4e1..9331ee099f 100644 --- a/classpath/java-lang.cpp +++ b/classpath/java-lang.cpp @@ -234,7 +234,8 @@ extern "C" JNIEXPORT void JNICALL Java_java_lang_Runtime_exec(JNIEnv* e, jclass, jobjectArray command, jlongArray process) { - char** argv = static_cast(malloc((e->GetArrayLength(command) + 1) * sizeof(char*))); + char** argv = static_cast + (malloc((e->GetArrayLength(command) + 1) * sizeof(char*))); int i; for(i = 0; i < e->GetArrayLength(command); i++){ jstring element = (jstring) e->GetObjectArrayElement(command, i); @@ -255,11 +256,11 @@ Java_java_lang_Runtime_exec(JNIEnv* e, jclass, makePipe(e, out); if(e->ExceptionCheck()) return; jlong outDescriptor = static_cast(out[1]); - e->SetLongArrayRegion(process, 1, 1, &outDescriptor); + e->SetLongArrayRegion(process, 2, 1, &outDescriptor); makePipe(e, err); if(e->ExceptionCheck()) return; jlong errDescriptor = static_cast(err[0]); - e->SetLongArrayRegion(process, 1, 1, &errDescriptor); + e->SetLongArrayRegion(process, 3, 1, &errDescriptor); makePipe(e, msg); if(e->ExceptionCheck()) return; if(fcntl(msg[1], F_SETFD, FD_CLOEXEC) != 0) {