On Fri, 21 Oct 2022 06:04:34 GMT, Jaikiran Pai <j...@openjdk.org> wrote:

>> Process.waitFor() throws IllegalThreadStateException when a process returns 
>> an exit code of 259.
>> As described in the bug report, `waitFor()` should not be sensitive to the 
>> exit value.
>> Previously, it erroneously threw IllegalStateException.
>> Added a test to verify.
>
> The reporter of the issue provided additional details that it was their own 
> application/program which was returning that exit value:
> 
>> I encountered it while prototyping an idea involving a Java application 
>> spawning a process running a C++ application that returned an exit value 
>> indicating the number of items it processed.
> 
> So this appears like the case where this change would help. I haven't found 
> any conclusive/official Windows documentation which forbids user applications 
> from returning this exit value (which represents `STILL_ACTIVE`).

@jaikiran There is advice against exiting with STILL_ACTIVE:
[GetExitCodeProcess](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getexitcodeprocess)
 says: 

> The GetExitCodeProcess function returns a valid error code defined by the 
> application only after the thread terminates. Therefore, an application 
> should not use STILL_ACTIVE (259) as an error code (STILL_ACTIVE is a macro 
> for STATUS_PENDING (minwinbase.h)). If a thread returns STILL_ACTIVE (259) as 
> an error code, then applications that test for that value could interpret it 
> to mean that the thread is still running, and continue to test for the 
> completion of the thread after the thread has terminated, which could put the 
> application into an infinite loop.

-------------

PR: https://git.openjdk.org/jdk/pull/10680

Reply via email to