Skip to content

fix: kill process plugin subprocesses so shutdown cannot hang - #1311

Merged
dsherret merged 4 commits into
dprint:mainfrom
entity-0-0-2:fix/process-plugin-deadlock
Oct 10, 2026
Merged

dsherret merged 4 commits into
dprint:mainfrom
entity-0-0-2:fix/process-plugin-deadlock

Conversation

@entity-0-0-2

@entity-0-0-2 entity-0-0-2 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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

entity-0-0-2 and others added 4 commits October 9, 2026 17:01
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.

@dsherret dsherret left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dsherret
dsherret merged commit d992858 into dprint:main Oct 10, 2026
22 checks passed
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.

dprint hangs when two process plugins run (.mts vs. .java)

2 participants