2016-05-14 Fritz Reese <fritzoreese@gmail.com>
[official-gcc.git] / libjava / java / lang / Win32Process.java
blobf22b548820f03286d8ab53b7579fede0b5ba2273
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
9 details. */
11 package java.lang;
13 import java.io.File;
14 import java.io.InputStream;
15 import java.io.OutputStream;
16 import java.io.IOException;
18 /**
19 * @author Adam Megacz
20 * @date Feb 24, 2002
23 // This is entirely internal to our implementation.
25 final class Win32Process extends Process
27 public native void destroy ();
29 public int exitValue ()
31 if (! hasExited ())
32 throw new IllegalThreadStateException ("Process has not exited");
34 return exitCode;
37 public InputStream getErrorStream ()
39 return errorStream;
42 public InputStream getInputStream ()
44 return inputStream;
47 public OutputStream getOutputStream ()
49 return outputStream;
52 public native int waitFor () throws InterruptedException;
54 public Win32Process (String[] progarray, String[] envp, File dir,
55 boolean redirect)
56 throws IOException
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.
79 private int exitCode;
81 private native boolean hasExited ();
82 private native void startProcess (String[] progarray,
83 String[] envp,
84 File dir,
85 boolean redirect)
86 throws IOException;
87 private native void cleanup ();
89 private static class EOFInputStream extends InputStream
91 static EOFInputStream instance = new EOFInputStream();
92 public int read()
94 return -1;