diff options
author | Bryce McKinlay <bryce@waitaki.otago.ac.nz> | 2001-09-24 04:51:50 +0000 |
---|---|---|
committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2001-09-24 05:51:50 +0100 |
commit | 4f7279ab3ef8e5ac64f2c8d45889196cf29d0d2a (patch) | |
tree | 33c2555a1c6fe8aeecedad3f79917cb12aaf94e5 /libjava/java/lang/natPosixProcess.cc | |
parent | 749ced524c4a4bcb7e8374854cc380e33e69a1d8 (diff) | |
download | gcc-4f7279ab3ef8e5ac64f2c8d45889196cf29d0d2a.zip gcc-4f7279ab3ef8e5ac64f2c8d45889196cf29d0d2a.tar.gz gcc-4f7279ab3ef8e5ac64f2c8d45889196cf29d0d2a.tar.bz2 |
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
Diffstat (limited to 'libjava/java/lang/natPosixProcess.cc')
-rw-r--r-- | libjava/java/lang/natPosixProcess.cc | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/libjava/java/lang/natPosixProcess.cc b/libjava/java/lang/natPosixProcess.cc index 5cce967..516fb04 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; |