Commit 4f7279ab by Bryce McKinlay Committed by Bryce McKinlay

PosixProcess.java (exitValue): Implement here.

	* java/lang/PosixProcess.java (exitValue): Implement here. Throw
	IllegalThreadStateException if process hasn't exited yet.
	* java/lang/natPosixProcess.cc (exitValue): Removed.
	(waitFor): Only check thread interrupted status if waitpid()
	returned an error. Use WIFEXITED and WEXITSTATUS to process process's
	exit value.

From-SVN: r45766
parent 749ced52
2001-09-24 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* java/lang/PosixProcess.java (exitValue): Implement here. Throw
IllegalThreadStateException if process hasn't exited yet.
* java/lang/natPosixProcess.cc (exitValue): Removed.
(waitFor): Only check thread interrupted status if waitpid() returned
an error. Use WIFEXITED and WEXITSTATUS to process process's exit
value.
2001-09-22 Anthony Green <green@redhat.com> 2001-09-22 Anthony Green <green@redhat.com>
* java/security/DummyKeyPairGenerator.java (initialize): New * java/security/DummyKeyPairGenerator.java (initialize): New
......
...@@ -26,7 +26,13 @@ import java.io.IOException; ...@@ -26,7 +26,13 @@ import java.io.IOException;
final class ConcreteProcess extends Process final class ConcreteProcess extends Process
{ {
public native void destroy (); public native void destroy ();
public native int exitValue ();
public int exitValue ()
{
if (! hasExited)
throw new IllegalThreadStateException("Process has not exited");
return status;
}
public InputStream getErrorStream () public InputStream getErrorStream ()
{ {
......
...@@ -49,27 +49,6 @@ java::lang::ConcreteProcess::destroy (void) ...@@ -49,27 +49,6 @@ java::lang::ConcreteProcess::destroy (void)
} }
jint jint
java::lang::ConcreteProcess::exitValue (void)
{
if (! hasExited)
{
int wstat;
pid_t r = waitpid ((pid_t) pid, &wstat, WNOHANG);
if (r == -1)
{
jstring x = JvNewStringLatin1 (strerror (errno));
throw new IllegalThreadStateException (x);
}
hasExited = true;
// Just use the raw status. FIXME: what is right?
status = wstat;
}
return status;
}
jint
java::lang::ConcreteProcess::waitFor (void) java::lang::ConcreteProcess::waitFor (void)
{ {
if (! hasExited) if (! hasExited)
...@@ -77,15 +56,21 @@ java::lang::ConcreteProcess::waitFor (void) ...@@ -77,15 +56,21 @@ java::lang::ConcreteProcess::waitFor (void)
int wstat; int wstat;
int r = waitpid ((pid_t) pid, &wstat, 0); int r = waitpid ((pid_t) pid, &wstat, 0);
if (r != -1) if (r == -1)
{
if (java::lang::Thread::interrupted())
throw new InterruptedException (JvNewStringLatin1 (strerror
(errno)));
}
else
{ {
hasExited = true; hasExited = true;
// Just use the raw status. FIXME: what is right?
status = wstat;
}
if (java::lang::Thread::interrupted()) if (WIFEXITED (wstat))
throw new InterruptedException (JvNewStringLatin1 ("wait interrupted")); status = WEXITSTATUS (wstat);
else
status = -1;
}
} }
return status; return status;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment