1 // Win32Process.java - Subclass of Process for Win32 systems.
3 /* Copyright (C) 2002, 2003, 2006, 2007 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
14 import java.io.InputStream;
15 import java.io.OutputStream;
16 import java.io.IOException;
23 // This is entirely internal to our implementation.
25 final class Win32Process extends Process
27 public native void destroy ();
29 public int exitValue ()
32 throw new IllegalThreadStateException ("Process has not exited");
37 public InputStream getErrorStream ()
42 public InputStream getInputStream ()
47 public OutputStream getOutputStream ()
52 public native int waitFor () throws InterruptedException;
54 public Win32Process (String[] progarray, String[] envp, File dir,
58 for (int i = 0; i < progarray.length; i++)
60 String s = progarray[i];
62 if ( (s.indexOf (' ') >= 0) || (s.indexOf ('\t') >= 0))
63 progarray[i] = "\"" + s + "\"";
66 startProcess (progarray, envp, dir, redirect);
69 // The standard streams (stdin, stdout and stderr, respectively)
70 // of the child as seen by the parent process.
71 private OutputStream outputStream;
72 private InputStream inputStream;
73 private InputStream errorStream;
75 // Handle to the child process - cast to HANDLE before use.
76 private int procHandle;
78 // Exit code of the child if it has exited.
81 private native boolean hasExited ();
82 private native void startProcess (String[] progarray,
87 private native void cleanup ();
89 private static class EOFInputStream extends InputStream
91 static EOFInputStream instance = new EOFInputStream();