Repository navigation
fix: kill process plugin subprocesses so shutdown cannot hang - #1311
Merged
Merged
Conversation
A process plugin that spawns its own subprocesses (ex. through a shell wrapper script) could keep the stdio pipes open after shutdown: when the plugin acknowledged the close message, the CLI never killed it, and killing only the direct child left spawned subprocesses holding the pipes. The blocked stdio reader threads then kept the CLI from exiting, which hung dprint forever with the plugin processes still alive. Spawn each plugin in its own process group, kill the whole group on shutdown, and kill unconditionally after the close acknowledgement or timeout. Also reap the child with wait after killing.
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.
dprint can hang forever at shutdown when a process plugin spawns a subprocess that outlives it (#969, futex wait captured in the issue).
Two gaps compound. shutdown() only killed a plugin after a timeout, so a plugin that acknowledged Close but did not exit was never killed. And plugins were spawned without a process group, so killing a wrapper left grandchildren alive holding the inherited stdio pipes. The per-plugin stdout and stderr reader tasks then block in read() forever and the runtime waits on them at exit.
Plugins now spawn in their own process group, kill() signals the whole group and waits for the child, and shutdown() kills unconditionally after the close handshake. A regression test with a protocol-correct plugin whose child holds the pipes hangs on main (45 second timeout) and exits in under a second with the fix. Full suite passes (1050 tests).
Fixes #969