mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
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.
This commit is contained in:
parent
cf14a2c222
commit
5cbfee467c
@ -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<char**>(malloc((e->GetArrayLength(command) + 1) * sizeof(char*)));
|
||||
char** argv = static_cast<char**>
|
||||
(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<jlong>(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<jlong>(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) {
|
||||
|
Loading…
Reference in New Issue
Block a user