Skip to content

Fix lingering processes on shutdown and PyInstaller failing to remove its temporary directory - #178

Merged
justvanrossum merged 7 commits into
mainfrom
temp-pull-176
Jul 23, 2025
Merged

Fix lingering processes on shutdown and PyInstaller failing to remove its temporary directory#178
justvanrossum merged 7 commits into
mainfrom
temp-pull-176

Conversation

@justvanrossum

@justvanrossum justvanrossum commented Jul 23, 2025

Copy link
Copy Markdown
Member

Supersedes #176.

The main change/fix was kindly contributed by @sintfar. Their description:

This change resolves an issue where subprocesses would linger after shutdown, particularly on Windows, preventing PyInstaller from removing its temporary directory.

We now use psutil to recursively terminate the process tree on all platforms. On Windows, we call terminate() on each process; elsewhere, we send SIGINT, similar to the original os.kill() behavior.

Note: psutil is cross-platform and now fully replaces os.kill() to support recursive cleanup. This was necessary on Windows and is potentially beneficial elsewhere, though only Windows was tested.

This appears to be the most robust solution. Both onedir and onefile builds revealed lingering processes after shutdown. The difference is that onefile unpacks to a temporary directory, making the issue more visible, as PyInstaller will emit a warning if cleanup fails.

Some build fixes were added by me: psutil somehow broke the macOS universal binary merge stuff.

sintfar and others added 7 commits July 16, 2025 00:27
@justvanrossum

Copy link
Copy Markdown
Member Author

@sintfar I will credit you as "sintfar" in the CHANGELOG and CONTRIBUTORS list (in the main repo), unless you prefer to provide a display name. thanks again!

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.

2 participants