fix(suspendapp): avoid deadlock and align JVM behaviour on system.exit#3930
Open
tKe wants to merge 1 commit into
Open
fix(suspendapp): avoid deadlock and align JVM behaviour on system.exit#3930tKe wants to merge 1 commit into
tKe wants to merge 1 commit into
Conversation
Contributor
Kover Report
|
Member
serras
reviewed
Jun 27, 2026
|
|
||
| override fun onSigTerm(block: suspend (code: Int) -> Unit): Unit = | ||
| addSignalHandler("SIGTERM") { block(15) } | ||
| addSignalHandler("TERM", block) |
Member
There was a problem hiding this comment.
Why is the change from SIGTERM to TERM needed?
Collaborator
Author
There was a problem hiding this comment.
sun.misc.Signal takes the signal name sans SIG prefix.
The example from the JavaDoc is:
Signal objects are created based on their names. For example:
new Signal("INT");
Previously these were throwing IllegalArgumentException on construction that were being caught and ignored.
Collaborator
Author
|
@serras rebasing this, which includes job name fixes for the js tests, highlighted that the exitApp change has introduced a regression in then wasm/js signal handling as it now reports an exitCode of 255 not 128+sig. I'll include a fix in this rebase. |
2272659 to
3b13f57
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #3846
This fix essentially sidesteps the deadlock by not attempting to cancel/graceful-shutdown when the hook is invoked for any reason other than SIGINT/SIGTERM.
The rationale is that
System.exitequivalents on other platforms doesn't trigger cancellation of the SuspendApp, and the other hook invocation cause (last non-daemon thread terminated) is not expected through the normal usage of SuspendApp (that is, as the entry point on the main thread for a service/application).Instead, this fixes the Signal handling, captures the signal, and limits triggering cancellation to only when signalled.