1999-05-12 13:23:44 +02:00
|
|
|
// PosixProcess.java - Subclass of Process for POSIX systems.
|
|
|
|
|
2000-03-07 20:55:28 +01:00
|
|
|
/* Copyright (C) 1998, 1999 Free Software Foundation
|
1999-05-12 13:23:44 +02:00
|
|
|
|
|
|
|
This file is part of libgcj.
|
|
|
|
|
|
|
|
This software is copyrighted work licensed under the terms of the
|
|
|
|
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
package java.lang;
|
|
|
|
|
2002-08-14 03:07:59 +02:00
|
|
|
import java.io.File;
|
1999-05-12 13:23:44 +02:00
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Tom Tromey <tromey@cygnus.com>
|
|
|
|
* @date May 3, 1999
|
|
|
|
*/
|
|
|
|
|
|
|
|
// This is entirely internal to our implementation.
|
|
|
|
|
|
|
|
// This file is copied to `ConcreteProcess.java' before compilation.
|
|
|
|
// Hence the class name apparently does not match the file name.
|
|
|
|
final class ConcreteProcess extends Process
|
|
|
|
{
|
|
|
|
public native void destroy ();
|
2001-09-24 06:51:50 +02:00
|
|
|
|
|
|
|
public int exitValue ()
|
|
|
|
{
|
|
|
|
if (! hasExited)
|
|
|
|
throw new IllegalThreadStateException("Process has not exited");
|
|
|
|
return status;
|
|
|
|
}
|
1999-05-12 13:23:44 +02:00
|
|
|
|
|
|
|
public InputStream getErrorStream ()
|
|
|
|
{
|
|
|
|
return errorStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
public InputStream getInputStream ()
|
|
|
|
{
|
|
|
|
return inputStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
public OutputStream getOutputStream ()
|
|
|
|
{
|
|
|
|
return outputStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
public native int waitFor () throws InterruptedException;
|
|
|
|
|
|
|
|
// This is used for actual initialization, as we can't write a
|
|
|
|
// native constructor.
|
2002-08-14 03:07:59 +02:00
|
|
|
public native void startProcess (String[] progarray,
|
|
|
|
String[] envp,
|
|
|
|
File dir)
|
1999-05-12 13:23:44 +02:00
|
|
|
throws IOException;
|
|
|
|
|
|
|
|
// This file is copied to `ConcreteProcess.java' before
|
|
|
|
// compilation. Hence the constructor name apparently does not
|
|
|
|
// match the file name.
|
2002-08-14 03:07:59 +02:00
|
|
|
public ConcreteProcess (String[] progarray,
|
|
|
|
String[] envp,
|
|
|
|
File dir)
|
|
|
|
throws IOException
|
1999-05-12 13:23:44 +02:00
|
|
|
{
|
2002-08-14 03:07:59 +02:00
|
|
|
startProcess (progarray, envp, dir);
|
1999-05-12 13:23:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// The process id. This is cast to a pid_t on the native side.
|
|
|
|
private long pid;
|
|
|
|
|
|
|
|
// True when child has exited.
|
|
|
|
private boolean hasExited;
|
|
|
|
|
|
|
|
// The exit status, if the child has exited.
|
|
|
|
private int status;
|
|
|
|
|
|
|
|
// The streams.
|
|
|
|
private InputStream errorStream;
|
|
|
|
private InputStream inputStream;
|
|
|
|
private OutputStream outputStream;
|
|
|
|
}
|