1 /* Process.java - Represent spawned system process.
2 Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 As a special exception, if you link this library with other files to
22 produce an executable, this library does not by itself cause the
23 resulting executable to be covered by the GNU General Public License.
24 This exception does not however invalidate any other reasons why the
25 executable file might be covered by the GNU General Public License. */
30 import java.io.OutputStream;
31 import java.io.InputStream;
33 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
37 * An instance of a subclass of <code>Process</code> is created by the
38 * <code>Runtime.exec</code> methods. Methods in <code>Process</code>
39 * provide a means to send input to a process, obtain the output from a
40 * subprocess, destroy a subprocess, obtain the exit value from a
41 * subprocess, and wait for a subprocess to complete.
46 * @author Tom Tromey <tromey@cygnus.com>
48 public abstract class Process
51 * Empty constructor does nothing.
56 * Obtain the output stream of the subprocess. It may help to
57 * associate this stream as the redirected STDIN file descriptor of
60 public abstract OutputStream getOutputStream();
63 * Obtain the input stream of the subprocess. It may help to
64 * associate this stream as the redirected STDOUT file descriptor of
67 public abstract InputStream getInputStream();
70 * Obtain the error input stream of the subprocess. It may help to
71 * associate this stream as the redirected STDERR file descriptor of
74 public abstract InputStream getErrorStream();
77 * The thread calling <code>waitFor</code> will block until the subprocess
78 * has terminated. If the process has already terminated then the method
79 * immediately returns with the exit value of the subprocess.
81 * @returns the exit value of the subprocess. A return of <code>0</code>
82 * denotes normal process termination by convention.
84 * @throws InterruptedException is thrown if another thread interrupts
85 * the waiting thread. The waiting thread stops waiting.
87 public abstract int waitFor()
88 throws InterruptedException;
91 * When a process terminates there is associated with that termination
92 * an exit value for the process to indicate why it terminated. A return
93 * of <code>0</code> denotes normal process termination by convention.
95 * @returns the exit value of the subprocess.
96 * @throws IllegalThreadStateException is thrown if the subprocess
97 * represented by the subclass of this class has not yet terminated.
99 public abstract int exitValue();
102 * Kills the subprocess and all of its children forcibly.
104 public abstract void destroy();