2002-02-25 00:17:26 +01:00
|
|
|
// Win32Process.java - Subclass of Process for Win32 systems.
|
|
|
|
|
2003-02-11 00:52:56 +01:00
|
|
|
/* Copyright (C) 2002, 2003 Free Software Foundation
|
2002-02-25 00:17:26 +01: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;
|
2002-02-25 00:17:26 +01:00
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Adam Megacz
|
|
|
|
* @date Feb 24, 2002
|
|
|
|
*/
|
|
|
|
|
|
|
|
// 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
|
|
|
|
{
|
2003-02-11 00:52:56 +01:00
|
|
|
public native void destroy ();
|
|
|
|
|
|
|
|
public native boolean hasExited ();
|
|
|
|
|
2002-02-25 00:17:26 +01:00
|
|
|
public int exitValue ()
|
|
|
|
{
|
2003-02-11 00:52:56 +01:00
|
|
|
if (! hasExited ())
|
|
|
|
throw new IllegalThreadStateException ("Process has not exited");
|
|
|
|
|
|
|
|
return exitCode;
|
2002-02-25 00:17:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public InputStream getErrorStream ()
|
|
|
|
{
|
2003-02-11 00:52:56 +01:00
|
|
|
return errorStream;
|
2002-02-25 00:17:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public InputStream getInputStream ()
|
|
|
|
{
|
2003-02-11 00:52:56 +01:00
|
|
|
return inputStream;
|
2002-02-25 00:17:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public OutputStream getOutputStream ()
|
|
|
|
{
|
2003-02-11 00:52:56 +01:00
|
|
|
return outputStream;
|
2002-02-25 00:17:26 +01:00
|
|
|
}
|
|
|
|
|
2003-02-11 00:52:56 +01:00
|
|
|
public native int waitFor () throws InterruptedException;
|
|
|
|
|
|
|
|
public native void startProcess (String[] progarray,
|
|
|
|
String[] envp,
|
|
|
|
File dir)
|
|
|
|
throws IOException;
|
|
|
|
|
|
|
|
public native void cleanup ();
|
2002-02-25 00:17:26 +01:00
|
|
|
|
2002-08-14 03:07:59 +02:00
|
|
|
public ConcreteProcess (String[] progarray,
|
|
|
|
String[] envp,
|
|
|
|
File dir)
|
|
|
|
throws IOException
|
2002-02-25 00:17:26 +01:00
|
|
|
{
|
2003-02-11 00:52:56 +01:00
|
|
|
startProcess (progarray, envp, dir);
|
2002-02-25 00:17:26 +01:00
|
|
|
}
|
|
|
|
|
2003-02-11 00:52:56 +01:00
|
|
|
// The standard streams (stdin, stdout and stderr, respectively)
|
|
|
|
// of the child as seen by the parent process.
|
|
|
|
private OutputStream outputStream;
|
|
|
|
private InputStream inputStream;
|
|
|
|
private InputStream errorStream;
|
|
|
|
|
|
|
|
// Handle to the child process - cast to HANDLE before use.
|
|
|
|
private int procHandle;
|
|
|
|
|
|
|
|
// Exit code of the child if it has exited.
|
|
|
|
private int exitCode;
|
2002-02-25 00:17:26 +01:00
|
|
|
}
|