2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / java / lang / Win32Process.java
blobb0ef487c2048fd8a2bfe849faf05f0e72ce9fce1
1 // Win32Process.java - Subclass of Process for Win32 systems.
3 /* Copyright (C) 2002, 2003 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 // This file is copied to `ConcreteProcess.java' before compilation.
26 // Hence the class name apparently does not match the file name.
27 final class ConcreteProcess extends Process
29 public native void destroy ();
31 public int exitValue ()
33 if (! hasExited ())
34 throw new IllegalThreadStateException ("Process has not exited");
36 return exitCode;
39 public InputStream getErrorStream ()
41 return errorStream;
44 public InputStream getInputStream ()
46 return inputStream;
49 public OutputStream getOutputStream ()
51 return outputStream;
54 public native int waitFor () throws InterruptedException;
56 public ConcreteProcess (String[] progarray,
57 String[] envp,
58 File dir)
59 throws IOException
61 for (int i = 0; i < progarray.length; i++)
63 String s = progarray[i];
65 if ( (s.indexOf (' ') >= 0) || (s.indexOf ('\t') >= 0))
66 progarray[i] = "\"" + s + "\"";
69 startProcess (progarray, envp, dir);
72 // The standard streams (stdin, stdout and stderr, respectively)
73 // of the child as seen by the parent process.
74 private OutputStream outputStream;
75 private InputStream inputStream;
76 private InputStream errorStream;
78 // Handle to the child process - cast to HANDLE before use.
79 private int procHandle;
81 // Exit code of the child if it has exited.
82 private int exitCode;
84 private native boolean hasExited ();
85 private native void startProcess (String[] progarray,
86 String[] envp,
87 File dir)
88 throws IOException;
89 private native void cleanup ();