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
This commit is contained in:
parent
749ced524c
commit
4f7279ab3e
3 changed files with 28 additions and 28 deletions
|
@ -48,27 +48,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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue