* java/lang/Win32Process.java: Added nested class EOFInputStream.
authormembar <membar@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Mar 2007 18:05:39 +0000 (18:05 +0000)
committermembar <membar@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Mar 2007 18:05:39 +0000 (18:05 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122668 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/classpath/lib/java/lang/Win32Process$EOFInputStream.class [new file with mode: 0644]
libjava/classpath/lib/java/lang/Win32Process.class
libjava/gcj/javaprims.h
libjava/java/lang/Win32Process$EOFInputStream.h [new file with mode: 0644]
libjava/java/lang/Win32Process.java
libjava/java/lang/natWin32Process.cc

index 10c39bf..47ad138 100644 (file)
@@ -1,3 +1,14 @@
+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.
diff --git a/libjava/classpath/lib/java/lang/Win32Process$EOFInputStream.class b/libjava/classpath/lib/java/lang/Win32Process$EOFInputStream.class
new file mode 100644 (file)
index 0000000..a43b1f1
Binary files /dev/null and b/libjava/classpath/lib/java/lang/Win32Process$EOFInputStream.class differ
index ef70db7..200aaaa 100644 (file)
Binary files a/libjava/classpath/lib/java/lang/Win32Process.class and b/libjava/classpath/lib/java/lang/Win32Process.class differ
index d7f3240..e4c29fe 100644 (file)
@@ -255,6 +255,7 @@ extern "Java"
       class VirtualMachineError;
       class Void;
       class Win32Process;
+      class Win32Process$EOFInputStream;
       namespace annotation
       {
         class Annotation;
diff --git a/libjava/java/lang/Win32Process$EOFInputStream.h b/libjava/java/lang/Win32Process$EOFInputStream.h
new file mode 100644 (file)
index 0000000..b0224f3
--- /dev/null
@@ -0,0 +1,23 @@
+
+// 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__
index e817a0c..f22b548 100644 (file)
@@ -85,4 +85,13 @@ final class Win32Process extends Process
                                    boolean redirect)
     throws IOException;
   private native void cleanup ();
+
+  private static class EOFInputStream extends InputStream
+  {
+    static EOFInputStream instance = new EOFInputStream();
+    public int read()
+    {
+      return -1;
+    }
+  }
 }
index c836b56..0e7f60d 100644 (file)
@@ -25,6 +25,7 @@ details.  */
 #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;
@@ -146,7 +147,7 @@ class ChildProcessPipe
 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();
@@ -163,8 +164,11 @@ private:
 };
 
 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.
@@ -195,7 +199,8 @@ ChildProcessPipe::~ChildProcessPipe()
   // 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()
@@ -284,7 +289,8 @@ java::lang::Win32Process::startProcess (jstringArray progarray,
       // 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 (),
@@ -292,7 +298,10 @@ java::lang::Win32Process::startProcess (jstringArray progarray,
       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));
 
@@ -310,7 +319,8 @@ java::lang::Win32Process::startProcess (jstringArray progarray,
 
       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