Skip to content

Preserve exit values above 127 when reaping children - #55

Merged
guillerodriguez merged 1 commit into
masterfrom
fix/process-exit-values-above-127
Aug 5, 2026
Merged

Preserve exit values above 127 when reaping children#55
guillerodriguez merged 1 commit into
masterfrom
fix/process-exit-values-above-127

Conversation

@guillerodriguez

Copy link
Copy Markdown
Contributor

When a child process exits with a code above 127, Process.waitFor() and Process.exitValue() return a negative number. This happens because VMProcess.nativeReap() incorrectly casts WEXITSTATUS() to jbyte (which is signed) before publishing it, so e.g. exit code 128 is reported as -128 and 250 as -6.

In addition, the incorrect values can be mistaken for signal deaths, which Classpath reports as the negative signal number (so -6 is what is reported when a child is killed by SIGABRT).

Fix by removing the incorrect jbyte cast.

Fixes #54 (BZ#126651)

When a child process exits with a code above 127, Process.waitFor()
and Process.exitValue() return a negative number. This happens because
VMProcess.nativeReap() incorrectly casts WEXITSTATUS() to jbyte (which
is signed) before publishing it, so e.g. exit code 128 is reported as
-128 and 250 as -6.

In addition, the incorrect values can be mistaken for signal deaths,
which Classpath reports as the negative signal number (so -6 is what
is reported when a child is killed by SIGABRT).

Fix by removing the incorrect jbyte cast.

Fixes #54 (BZ#126651)

Signed-off-by: Guillermo Rodríguez <grodriguez@ingelabs.com>
@guillerodriguez
guillerodriguez requested a review from phvega August 5, 2026 08:36
@guillerodriguez
guillerodriguez merged commit de6819e into master Aug 5, 2026
3 checks passed
@guillerodriguez
guillerodriguez deleted the fix/process-exit-values-above-127 branch August 5, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Process exit values above 127 are returned as negative numbers

2 participants