| 1 | // PosixProcess.java - Subclass of Process for POSIX systems.
|
|---|
| 2 |
|
|---|
| 3 | /* Copyright (C) 1998, 1999 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.InputStream;
|
|---|
| 14 | import java.io.OutputStream;
|
|---|
| 15 | import java.io.IOException;
|
|---|
| 16 |
|
|---|
| 17 | /**
|
|---|
| 18 | * @author Tom Tromey <[email protected]>
|
|---|
| 19 | * @date May 3, 1999
|
|---|
| 20 | */
|
|---|
| 21 |
|
|---|
| 22 | // This is entirely internal to our implementation.
|
|---|
| 23 |
|
|---|
| 24 | // This file is copied to `ConcreteProcess.java' before compilation.
|
|---|
| 25 | // Hence the class name apparently does not match the file name.
|
|---|
| 26 | final class ConcreteProcess extends Process
|
|---|
| 27 | {
|
|---|
| 28 | public native void destroy ();
|
|---|
| 29 |
|
|---|
| 30 | public int exitValue ()
|
|---|
| 31 | {
|
|---|
| 32 | if (! hasExited)
|
|---|
| 33 | throw new IllegalThreadStateException("Process has not exited");
|
|---|
| 34 | return status;
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | public InputStream getErrorStream ()
|
|---|
| 38 | {
|
|---|
| 39 | return errorStream;
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | public InputStream getInputStream ()
|
|---|
| 43 | {
|
|---|
| 44 | return inputStream;
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | public OutputStream getOutputStream ()
|
|---|
| 48 | {
|
|---|
| 49 | return outputStream;
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | public native int waitFor () throws InterruptedException;
|
|---|
| 53 |
|
|---|
| 54 | // This is used for actual initialization, as we can't write a
|
|---|
| 55 | // native constructor.
|
|---|
| 56 | public native void startProcess (String[] progarray, String[] envp)
|
|---|
| 57 | throws IOException;
|
|---|
| 58 |
|
|---|
| 59 | // This file is copied to `ConcreteProcess.java' before
|
|---|
| 60 | // compilation. Hence the constructor name apparently does not
|
|---|
| 61 | // match the file name.
|
|---|
| 62 | public ConcreteProcess (String[] progarray, String[] envp) throws IOException
|
|---|
| 63 | {
|
|---|
| 64 | startProcess (progarray, envp);
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | // The process id. This is cast to a pid_t on the native side.
|
|---|
| 68 | private long pid;
|
|---|
| 69 |
|
|---|
| 70 | // True when child has exited.
|
|---|
| 71 | private boolean hasExited;
|
|---|
| 72 |
|
|---|
| 73 | // The exit status, if the child has exited.
|
|---|
| 74 | private int status;
|
|---|
| 75 |
|
|---|
| 76 | // The streams.
|
|---|
| 77 | private InputStream errorStream;
|
|---|
| 78 | private InputStream inputStream;
|
|---|
| 79 | private OutputStream outputStream;
|
|---|
| 80 | }
|
|---|