Skip to content

fix(posix): reap exited plugin children during shutdown - #937

Open
Adiker wants to merge 1 commit into
SteamClientHomebrew:mainfrom
Adiker:codex/posix-plugin-exit-delay
Open

Adiker wants to merge 1 commit into
SteamClientHomebrew:mainfrom
Adiker:codex/posix-plugin-exit-delay

Conversation

@Adiker

@Adiker Adiker commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Summary

On POSIX, PluginProcess checks kill(pid, 0) for up to three seconds before calling waitpid(). An exited child remains visible to kill(pid, 0) while it is a zombie, so even a successful plugin shutdown consumes the entire grace period. Destructing six plugin processes sequentially adds about 18 seconds to shutdown.

Poll and reap children with waitpid(..., WNOHANG) instead. Retry interrupted waits, accept an already reaped child, and retain the existing SIGTERM, three-second grace period, and SIGKILL fallback for a child that actually stays alive. Windows behavior is unchanged.

Add four POSIX regression cases using the real PluginProcess and IPC implementation: an unreaped zombie, an already reaped child, a child that exits on SIGTERM, and one that ignores SIGTERM.

Validation

  • On the original destructor, the zombie and SIGTERM cases both fail after 3002 ms.
  • On this branch, all four cases pass in a 32-bit Linux Debug build with -Wall -Wextra -Werror: 0 ms, 0 ms, 100 ms, and 3002 ms respectively.
  • All four cases also pass in a 64-bit ASan/UBSan build with no sanitizer reports.
  • Live Steam testing on Linux with Millennium 3.6.1 and six plugins: the plugin shutdown timer dropped from 18012–18013 ms to 601 ms in two consecutive exits; both logged Millennium unloaded successfully, with no Steam coredumps or remaining Steam/plugin processes. This was an incremental comparison with other local shutdown fixes held constant; the live installation includes those separate fixes.

The regression test can be run independently:

cmake -S tests/cpp/child_shutdown -B build/child-shutdown -DCMAKE_BUILD_TYPE=Debug
cmake --build build/child-shutdown --parallel 1
ctest --test-dir build/child-shutdown --output-on-failure

This branch has not been deployed

No deployments
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.

1 participant