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