Title: Stop with integratedTerminal/externalTerminal still uses vm.exit(0), shutdown hooks do not run · Issue #1732 · microsoft/vscode-java-debug · GitHub
Open Graph Title: Stop with integratedTerminal/externalTerminal still uses vm.exit(0), shutdown hooks do not run · Issue #1732 · microsoft/vscode-java-debug
X Title: Stop with integratedTerminal/externalTerminal still uses vm.exit(0), shutdown hooks do not run · Issue #1732 · microsoft/vscode-java-debug
Description: Follow-up to #1720 (fixed by microsoft/java-debug#645). Since 0.60.2026102705, the first Stop sends terminate, keeps JDI attached, and the JVM shuts down gracefully, so breakpoints in shutdown hooks are hit. This works with "console": "i...
Open Graph Description: Follow-up to #1720 (fixed by microsoft/java-debug#645). Since 0.60.2026102705, the first Stop sends terminate, keeps JDI attached, and the JVM shuts down gracefully, so breakpoints in shutdown hook...
X Description: Follow-up to #1720 (fixed by microsoft/java-debug#645). Since 0.60.2026102705, the first Stop sends terminate, keeps JDI attached, and the JVM shuts down gracefully, so breakpoints in shutdown hook...
Opengraph URL: https://github.com/microsoft/vscode-java-debug/issues/1732
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Stop with integratedTerminal/externalTerminal still uses vm.exit(0), shutdown hooks do not run","articleBody":"Follow-up to #1720 (fixed by microsoft/java-debug#645).\n\nSince 0.60.2026102705, the first **Stop** sends `terminate`, keeps JDI attached, and the JVM shuts down gracefully, so breakpoints in shutdown hooks are hit. This works with `\"console\": \"internalConsole\"`. With `\"console\": \"integratedTerminal\"` or `\"externalTerminal\"` the problem from #1720 is still there: shutdown hooks do not run at all.\n\n##### Environment\n- Operating System: Linux Mint 22.1\n- JDK version: 21.0.7\n- Java Debugger extension version: 0.60.2026102705 or later\n\n##### Steps To Reproduce\n1. Use the program from #1720:\n ```java\n public class App {\n public static void main(String[] args) throws Exception {\n Runtime.getRuntime().addShutdownHook(new Thread(() -> {\n System.out.println(\"hook start\"); // breakpoint here\n System.out.println(\"hook end\");\n }));\n Thread.sleep(Long.MAX_VALUE);\n }\n }\n ```\n2. Launch it with `\"console\": \"integratedTerminal\"` (or `\"externalTerminal\"`).\n3. Set a breakpoint on the `hook start` line.\n4. Press **Stop**.\n\n##### Current Result\nThe JVM is killed: the breakpoint is not hit and `hook start` is not printed in the terminal.\n\n##### Expected Result\nThe same as with `internalConsole`: the JVM gets SIGTERM, the debugger stays attached, the shutdown-hook breakpoint is hit, and the session ends when the JVM exits.\n\n##### Additional Informations\n`TerminateRequestHandler` calls `debugSession.terminate()`, and [`DebugSession.terminate()`](https://github.com/microsoft/java-debug/blob/main/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugSession.java) does:\n\n```java\nif (vm.process() != null && vm.process().isAlive()) {\n vm.process().destroy();\n} else if (vm.process() == null || vm.process().isAlive()) {\n vm.exit(0);\n}\n```\n\nIn terminal mode the debuggee is started through `runInTerminal` and connects to a `ListeningConnector`, so `vm.process()` is `null` and the code falls back to `vm.exit(0)`. JDWP `VirtualMachine.Exit` ends the JVM without running shutdown hooks.\n\n`DebuggeeProcessHelper.terminate()` can already destroy the process by `context.getProcessId()`, but it is only used when there is no debug session (`noDebug`). Even there it does not point to the JVM: VS Code's `runInTerminal` response gives the PID of the terminal shell, not of the debuggee.\n","author":{"url":"https://github.com/danilaslynko","@type":"Person","name":"danilaslynko"},"datePublished":"2026-11-12T21:13:50Z","url":"https://github.com/microsoft/vscode-java-debug/issues/1732"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d4e12da6-ea6b-11aa-b88b-7b6a2ec71883 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DCE4:1D11BA:1D4FB9:29CA75:6AF7487C |
| html-safe-nonce | a9bdb796a0f7d8276bff5b6f9c61c04465a7934c9094dd03559e3c80fca97f27 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0U0OjFEMTFCQToxRDRGQjk6MjlDQTc1OjZBRjc0ODdDIiwidmlzaXRvcl9pZCI6IjE2MzUxMDgyOTM0OTMzNDQzODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 05226b040e82ec87534a72b7298c483f3bc93b432ba276a51e295caaba3afce5 |
| hovercard-subject-tag | issue:6359147534 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/vscode-java-debug/1732/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d2861e8d9bacd40dcc0c4df47522734bb5b8c9bf6ab6557452a718e84260e264/microsoft/vscode-java-debug/issues/1732 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d2861e8d9bacd40dcc0c4df47522734bb5b8c9bf6ab6557452a718e84260e264/microsoft/vscode-java-debug/issues/1732 |
| og:image:alt | Follow-up to #1720 (fixed by microsoft/java-debug#645). Since 0.60.2026102705, the first Stop sends terminate, keeps JDI attached, and the JVM shuts down gracefully, so breakpoints in shutdown hook... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | danilaslynko |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4494f30df164445f3982ac48dcefb5f11a2d1e1f60dbda4bc38699650f7bda40 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/vscode-java-debug git https://github.com/microsoft/vscode-java-debug.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 102584737 |
| octolytics-dimension-repository_nwo | microsoft/vscode-java-debug |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 102584737 |
| octolytics-dimension-repository_network_root_nwo | microsoft/vscode-java-debug |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c5e54d8b38df3667eb26cd4f3ee42355f44e009c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width