OSDN Git Service

* java/io/FileWriter.java: Merge with Classpath.
[pf3gnuchains/gcc-fork.git] / libjava / java / lang / Process.java
1 /* Process.java - Represent spawned system process.
2    Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
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)
9 any later version.
10  
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.
15
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
19 02111-1307 USA.
20
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. */
26
27
28 package java.lang;
29
30 import java.io.OutputStream;
31 import java.io.InputStream;
32
33 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
34  */
35
36 /**
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.
42  * 
43  * @since JDK 1.0
44  * 
45  * @author Brian Jones
46  * @author Tom Tromey <tromey@cygnus.com>
47  */
48 public abstract class Process
49 {
50   /**
51    * Empty constructor does nothing.
52    */
53   public Process() { }
54
55   /**
56    * Obtain the output stream of the subprocess.  It may help to 
57    * associate this stream as the redirected STDIN file descriptor of
58    * the subprocess.
59    */
60   public abstract OutputStream getOutputStream();
61
62   /**
63    * Obtain the input stream of the subprocess.  It may help to 
64    * associate this stream as the redirected STDOUT file descriptor of
65    * the subprocess.
66    */
67   public abstract InputStream getInputStream();
68
69   /**
70    * Obtain the error input stream of the subprocess.  It may help to 
71    * associate this stream as the redirected STDERR file descriptor of
72    * the subprocess.
73    */
74   public abstract InputStream getErrorStream();
75
76   /**
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.
80    * 
81    * @returns the exit value of the subprocess.  A return of <code>0</code> 
82    * denotes normal process termination by convention.
83    *
84    * @throws InterruptedException is thrown if another thread interrupts 
85    * the waiting thread.  The waiting thread stops waiting.
86    */
87   public abstract int waitFor()
88     throws InterruptedException;
89
90   /**
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.
94    *
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.
98    */
99   public abstract int exitValue();
100
101   /**
102    * Kills the subprocess and all of its children forcibly.
103    */
104   public abstract void destroy();
105
106 }