+2007-03-07 Mohan Embar <gnustuff@thisiscool.com>
+
+ * java/lang/Win32Process.java: Added nested class EOFInputStream.
+ * java/lang/natWin32Process.cc (ChildProcessPipe): Added DUMMY
+ enum and implementation.
+ (startProcess): Use redirect flag.
+ * classpath/lib/java/lang/Win32Process.class: Regenerated.
+ * classpath/lib/java/lang/Win32Process$EOFInputStream.class: New.
+ * gcj/javaprims.h: Regenerated.
+ * java/lang/Win32Process$EOFInputStream.h: New.
+
2007-03-07 Andrew Haley <aph@redhat.com>
* libgcj_bc.c (JvRunMainName): Declare.
--- /dev/null
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_lang_Win32Process$EOFInputStream__
+#define __java_lang_Win32Process$EOFInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+
+class java::lang::Win32Process$EOFInputStream : public ::java::io::InputStream
+{
+
+ Win32Process$EOFInputStream();
+public:
+ virtual jint read();
+public: // actually package-private
+ static ::java::lang::Win32Process$EOFInputStream * instance;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_lang_Win32Process$EOFInputStream__
#include <java/io/FileOutputStream.h>
#include <java/io/IOException.h>
#include <java/lang/OutOfMemoryError.h>
+#include <java/lang/Win32Process$EOFInputStream.h>
#include <gnu/java/nio/channels/FileChannelImpl.h>
using gnu::java::nio::channels::FileChannelImpl;
public:
// Indicates from the child process' point of view
// whether the pipe is for reading or writing.
- enum EType {INPUT, OUTPUT};
+ enum EType {INPUT, OUTPUT, DUMMY};
ChildProcessPipe(EType eType);
~ChildProcessPipe();
};
ChildProcessPipe::ChildProcessPipe(EType eType):
- m_eType(eType)
+ m_eType(eType), m_hRead(0), m_hWrite(0)
{
+ if (eType == DUMMY)
+ return;
+
SECURITY_ATTRIBUTES sAttrs;
// Explicitly allow the handles to the pipes to be inherited.
// Close the parent end of the pipe. This
// destructor is called after the child process
// has been spawned.
- CloseHandle(getChildHandle());
+ if (m_eType != DUMMY)
+ CloseHandle(getChildHandle());
}
HANDLE ChildProcessPipe::getParentHandle()
// on each of standard streams.
ChildProcessPipe aChildStdIn(ChildProcessPipe::INPUT);
ChildProcessPipe aChildStdOut(ChildProcessPipe::OUTPUT);
- ChildProcessPipe aChildStdErr(ChildProcessPipe::OUTPUT);
+ ChildProcessPipe aChildStdErr(redirect ? ChildProcessPipe::DUMMY
+ : ChildProcessPipe::OUTPUT);
outputStream = new FileOutputStream (new FileChannelImpl (
(jint) aChildStdIn.getParentHandle (),
inputStream = new FileInputStream (new FileChannelImpl (
(jint) aChildStdOut.getParentHandle (),
FileChannelImpl::READ));
- errorStream = new FileInputStream (new FileChannelImpl (
+ if (redirect)
+ errorStream = Win32Process$EOFInputStream::instance;
+ else
+ errorStream = new FileInputStream (new FileChannelImpl (
(jint) aChildStdErr.getParentHandle (),
FileChannelImpl::READ));
si.hStdInput = aChildStdIn.getChildHandle();
si.hStdOutput = aChildStdOut.getChildHandle();
- si.hStdError = aChildStdErr.getChildHandle();
+ si.hStdError = redirect ? aChildStdOut.getChildHandle()
+ : aChildStdErr.getChildHandle();
// Spawn the process. CREATE_NO_WINDOW only applies when
// starting a console application; it suppresses the