Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libjava / java / lang / Process.java
blobe8c52760dfe5d6ae96136ee76f029e58488b103e
1 /* Process.java - Represent spawned system process
2 Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005
3 Free Software Foundation, Inc.
5 This file is part of GNU Classpath.
7 GNU Classpath is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU Classpath is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Classpath; see the file COPYING. If not, write to the
19 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA.
22 Linking this library statically or dynamically with other modules is
23 making a combined work based on this library. Thus, the terms and
24 conditions of the GNU General Public License cover the whole
25 combination.
27 As a special exception, the copyright holders of this library give you
28 permission to link this library with independent modules to produce an
29 executable, regardless of the license terms of these independent
30 modules, and to copy and distribute the resulting executable under
31 terms of your choice, provided that you also meet, for each linked
32 independent module, the terms and conditions of the license of that
33 module. An independent module is a module which is not derived from
34 or based on this library. If you modify this library, you may extend
35 this exception to your version of the library, but you are not
36 obligated to do so. If you do not wish to do so, delete this
37 exception statement from your version. */
40 package java.lang;
42 import java.io.InputStream;
43 import java.io.OutputStream;
45 /**
46 * An instance of a subclass of <code>Process</code> is created by the
47 * <code>Runtime.exec</code> methods. Methods in <code>Process</code>
48 * provide a means to send input to a process, obtain the output from a
49 * subprocess, destroy a subprocess, obtain the exit value from a
50 * subprocess, and wait for a subprocess to complete.
52 * <p>This is dependent on the platform, and some processes (like native
53 * windowing processes, 16-bit processes in Windows, or shell scripts) may
54 * be limited in functionality. Because some platforms have limited buffers
55 * between processes, you may need to provide input and read output to prevent
56 * the process from blocking, or even deadlocking.
58 * <p>Even if all references to this object disapper, the process continues
59 * to execute to completion. There are no guarantees that the
60 * subprocess execute asynchronously or concurrently with the process which
61 * owns this object.
63 * @author Brian Jones
64 * @author Tom Tromey (tromey@cygnus.com)
65 * @see Runtime#exec(String[], String[], File)
66 * @since 1.0
67 * @status updated to 1.4
69 public abstract class Process
71 /**
72 * Empty constructor does nothing.
74 public Process()
78 /**
79 * Obtain the output stream that sends data to the subprocess. This is
80 * the STDIN of the subprocess. When implementing, you should probably
81 * use a buffered stream.
83 * @return the output stream that pipes to the process input
85 public abstract OutputStream getOutputStream();
87 /**
88 * Obtain the input stream that receives data from the subprocess. This is
89 * the STDOUT of the subprocess. When implementing, you should probably
90 * use a buffered stream.
92 * @return the input stream that pipes data from the process output
94 public abstract InputStream getInputStream();
96 /**
97 * Obtain the input stream that receives data from the subprocess. This is
98 * the STDERR of the subprocess. When implementing, you should probably
99 * use a buffered stream.
101 * @return the input stream that pipes data from the process error output
103 public abstract InputStream getErrorStream();
106 * The thread calling <code>waitFor</code> will block until the subprocess
107 * has terminated. If the process has already terminated then the method
108 * immediately returns with the exit value of the subprocess.
110 * @return the subprocess exit value; 0 conventionally denotes success
111 * @throws InterruptedException if another thread interrupts the blocked one
113 public abstract int waitFor() throws InterruptedException;
116 * When a process terminates there is associated with that termination
117 * an exit value for the process to indicate why it terminated. A return
118 * of <code>0</code> denotes normal process termination by convention.
120 * @return the exit value of the subprocess
121 * @throws IllegalThreadStateException if the subprocess has not terminated
123 public abstract int exitValue();
126 * Kills the subprocess and all of its children forcibly.
128 public abstract void destroy();
129 } // class Process