1 | // Win32Process.java - Subclass of Process for Win32 systems.
|
---|
2 |
|
---|
3 | /* Copyright (C) 2002, 2003 Free Software Foundation
|
---|
4 |
|
---|
5 | This file is part of libgcj.
|
---|
6 |
|
---|
7 | This software is copyrighted work licensed under the terms of the
|
---|
8 | Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
---|
9 | details. */
|
---|
10 |
|
---|
11 | package java.lang;
|
---|
12 |
|
---|
13 | import java.io.File;
|
---|
14 | import java.io.InputStream;
|
---|
15 | import java.io.OutputStream;
|
---|
16 | import java.io.IOException;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * @author Adam Megacz
|
---|
20 | * @date Feb 24, 2002
|
---|
21 | */
|
---|
22 |
|
---|
23 | // This is entirely internal to our implementation.
|
---|
24 |
|
---|
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
|
---|
28 | {
|
---|
29 | public native void destroy ();
|
---|
30 |
|
---|
31 | public native boolean hasExited ();
|
---|
32 |
|
---|
33 | public int exitValue ()
|
---|
34 | {
|
---|
35 | if (! hasExited ())
|
---|
36 | throw new IllegalThreadStateException ("Process has not exited");
|
---|
37 |
|
---|
38 | return exitCode;
|
---|
39 | }
|
---|
40 |
|
---|
41 | public InputStream getErrorStream ()
|
---|
42 | {
|
---|
43 | return errorStream;
|
---|
44 | }
|
---|
45 |
|
---|
46 | public InputStream getInputStream ()
|
---|
47 | {
|
---|
48 | return inputStream;
|
---|
49 | }
|
---|
50 |
|
---|
51 | public OutputStream getOutputStream ()
|
---|
52 | {
|
---|
53 | return outputStream;
|
---|
54 | }
|
---|
55 |
|
---|
56 | public native int waitFor () throws InterruptedException;
|
---|
57 |
|
---|
58 | public native void startProcess (String[] progarray,
|
---|
59 | String[] envp,
|
---|
60 | File dir)
|
---|
61 | throws IOException;
|
---|
62 |
|
---|
63 | public native void cleanup ();
|
---|
64 |
|
---|
65 | public ConcreteProcess (String[] progarray,
|
---|
66 | String[] envp,
|
---|
67 | File dir)
|
---|
68 | throws IOException
|
---|
69 | {
|
---|
70 | startProcess (progarray, envp, dir);
|
---|
71 | }
|
---|
72 |
|
---|
73 | // The standard streams (stdin, stdout and stderr, respectively)
|
---|
74 | // of the child as seen by the parent process.
|
---|
75 | private OutputStream outputStream;
|
---|
76 | private InputStream inputStream;
|
---|
77 | private InputStream errorStream;
|
---|
78 |
|
---|
79 | // Handle to the child process - cast to HANDLE before use.
|
---|
80 | private int procHandle;
|
---|
81 |
|
---|
82 | // Exit code of the child if it has exited.
|
---|
83 | private int exitCode;
|
---|
84 | }
|
---|