Commit 881ad9e4 by Per Bothner

natPosixProcess.cc (startProcess): Implement standard streams using…

natPosixProcess.cc (startProcess): Implement standard streams using FileChannelImpl, not FileDescriptor.


	* java/lang/natPosixProcess.cc (startProcess):  Implement standard
	streams using FileChannelImpl, not FileDescriptor.
	* java/lang/natWin32Process.cc (startProcess):  Likewise.

From-SVN: r78664
parent 3ae1e52c
...@@ -32,11 +32,14 @@ details. */ ...@@ -32,11 +32,14 @@ details. */
#include <java/lang/Thread.h> #include <java/lang/Thread.h>
#include <java/io/File.h> #include <java/io/File.h>
#include <java/io/FileDescriptor.h> #include <java/io/FileDescriptor.h>
#include <gnu/java/nio/channels/FileChannelImpl.h>
#include <java/io/FileInputStream.h> #include <java/io/FileInputStream.h>
#include <java/io/FileOutputStream.h> #include <java/io/FileOutputStream.h>
#include <java/io/IOException.h> #include <java/io/IOException.h>
#include <java/lang/OutOfMemoryError.h> #include <java/lang/OutOfMemoryError.h>
using gnu::java::nio::channels::FileChannelImpl;
extern char **environ; extern char **environ;
void void
...@@ -187,9 +190,9 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray, ...@@ -187,9 +190,9 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray,
// We create the streams before forking. Otherwise if we had an // We create the streams before forking. Otherwise if we had an
// error while creating the streams we would have run the child // error while creating the streams we would have run the child
// with no way to communicate with it. // with no way to communicate with it.
errorStream = new FileInputStream (new FileDescriptor (errp[0])); errorStream = new FileInputStream (new FileChannelImpl(errp[0], FileChannelImpl::READ));
inputStream = new FileInputStream (new FileDescriptor (inp[0])); inputStream = new FileInputStream (new FileChannelImpl(inp[0], FileChannelImpl::READ));
outputStream = new FileOutputStream (new FileDescriptor (outp[1])); outputStream = new FileOutputStream (new FileChannelImpl(outp[0], FileChannelImpl::WRITE));
// We don't use vfork() because that would cause the local // We don't use vfork() because that would cause the local
// environment to be set by the child. // environment to be set by the child.
......
...@@ -25,6 +25,9 @@ details. */ ...@@ -25,6 +25,9 @@ details. */
#include <java/io/FileOutputStream.h> #include <java/io/FileOutputStream.h>
#include <java/io/IOException.h> #include <java/io/IOException.h>
#include <java/lang/OutOfMemoryError.h> #include <java/lang/OutOfMemoryError.h>
#include <gnu/java/nio/channels/FileChannelImpl.h>
using gnu::java::nio::channels::FileChannelImpl;
void void
java::lang::ConcreteProcess::cleanup (void) java::lang::ConcreteProcess::cleanup (void)
...@@ -282,12 +285,15 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray, ...@@ -282,12 +285,15 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray,
ChildProcessPipe aChildStdOut(ChildProcessPipe::OUTPUT); ChildProcessPipe aChildStdOut(ChildProcessPipe::OUTPUT);
ChildProcessPipe aChildStdErr(ChildProcessPipe::OUTPUT); ChildProcessPipe aChildStdErr(ChildProcessPipe::OUTPUT);
outputStream = new FileOutputStream (new FileDescriptor ( outputStream = new FileOutputStream (new FileChannelImpl (
(jint) aChildStdIn.getParentHandle ())); (jint) aChildStdIn.getParentHandle (),
inputStream = new FileInputStream (new FileDescriptor ( FileChannelImpl::WRITE));
(jint) aChildStdOut.getParentHandle ())); inputStream = new FileInputStream (new FileChannelImpl (
errorStream = new FileInputStream (new FileDescriptor ( (jint) aChildStdOut.getParentHandle (),
(jint) aChildStdErr.getParentHandle ())); FileChannelImpl::READ));
errorStream = new FileInputStream (new FileChannelImpl (
(jint) aChildStdErr.getParentHandle (),
FileChannelImpl::READ));
// Now create the child process. // Now create the child process.
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment