summaryrefslogtreecommitdiffstats
path: root/libjava/java/lang
diff options
context:
space:
mode:
authorbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2001-09-24 04:51:50 +0000
committerbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2001-09-24 04:51:50 +0000
commitc45e1891954393477056fdc0e52887903f22a737 (patch)
tree33c2555a1c6fe8aeecedad3f79917cb12aaf94e5 /libjava/java/lang
parent5124a2c8eabf7035b98321a52a51a4998c207062 (diff)
downloadppe42-gcc-c45e1891954393477056fdc0e52887903f22a737.tar.gz
ppe42-gcc-c45e1891954393477056fdc0e52887903f22a737.zip
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45766 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/lang')
-rw-r--r--libjava/java/lang/PosixProcess.java8
-rw-r--r--libjava/java/lang/natPosixProcess.cc39
2 files changed, 19 insertions, 28 deletions
diff --git a/libjava/java/lang/PosixProcess.java b/libjava/java/lang/PosixProcess.java
index 36182598b3b..459f76c3da7 100644
--- a/libjava/java/lang/PosixProcess.java
+++ b/libjava/java/lang/PosixProcess.java
@@ -26,7 +26,13 @@ import java.io.IOException;
final class ConcreteProcess extends Process
{
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 ()
{
diff --git a/libjava/java/lang/natPosixProcess.cc b/libjava/java/lang/natPosixProcess.cc
index 5cce9674c9a..516fb045fd7 100644
--- a/libjava/java/lang/natPosixProcess.cc
+++ b/libjava/java/lang/natPosixProcess.cc
@@ -49,27 +49,6 @@ java::lang::ConcreteProcess::destroy (void)
}
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)
{
if (! hasExited)
@@ -77,15 +56,21 @@ java::lang::ConcreteProcess::waitFor (void)
int wstat;
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;
- // Just use the raw status. FIXME: what is right?
- status = wstat;
- }
- if (java::lang::Thread::interrupted())
- throw new InterruptedException (JvNewStringLatin1 ("wait interrupted"));
+ if (WIFEXITED (wstat))
+ status = WEXITSTATUS (wstat);
+ else
+ status = -1;
+ }
}
return status;
OpenPOWER on IntegriCloud