Repository navigation
fix(desktop): start the engine's child processes without forking on macOS - #2287
Merged
Merged
Conversation
…acOS With Tcl loaded in the engine, a child that Python forks on macOS 26 can stop for good while it closes inherited descriptors, and the engine then waits inside Popen with no timeout that applies. The engine's own child processes (the Flow CLI, chmod, ffprobe and ffmpeg, the portal console) now start through openadapt_desktop.child_process, which lets Python use posix_spawn. A test fails if an engine module starts a process directly.
Member
Author
Independent adversarial review: APPROVEFrom: Grok Are any engine subprocess paths still on fork?
Does
Windows and Linux
Tests run: P3s
Not run: macOS. The fork-stall fix still needs proving on a macOS 26 run on main, or on a release build, before 0.30.5 ships. Still to decide (maintainers): merging and the 0.30.5 release. |
This was referenced Nov 20, 2026
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.
The installed engine can wait forever when it starts a helper process on macOS 26. This makes the engine's own helper processes start without a fork, and bumps Desktop to 0.30.5.
Cause
A child that Python forks stops in
close()while it closes inherited descriptors, when Tcl is loaded in the parent. Tcl starts its notifier thread in every forked child. On the hosted macOS 26 runners, a script that only imports tkinter stalled 33 times in about 266,000 forks; without tkinter, or withposix_spawn, it did not stall in 400,000 starts or more (evidence and samples in #2282).The engine loads Tcl: the published openadapt-capture 1.3.0 imports Pympler, which imports tkinter, when the recorder is imported. The 0.30.3 macOS build log shows PyInstaller bundling
_tkinter(job 135798832682: "Processing standard module hook 'hook-_tkinter.py'", "Including run-time hook 'pyi_rth__tkinter.py'").Fix
openadapt_desktop/child_process.pyaddsrunandpopen. On POSIX they setclose_fds=Falseand resolve a bare program name to its absolute path, which are the conditions under which Python starts the child withposix_spawn. Python opens its own descriptors close-on-exec, so the child still inherits only its standard streams. They refusecwd,start_new_session,preexec_fnandpass_fds, each of which would bring the fork back. On Windows they pass everything through unchanged.The engine's process starts now go through them:
flow_bridge.py(the defaultrunnerandpopen)/bin/chmodinapprover_anchor.pypresentation_export.pytaskkillinportal/service.pyTests
tests/test_engine/test_child_process.py:openadapt_desktop/refers tosubprocess.run,subprocess.Popenand the like, or toos.system,os.popen,os.forkoros.spawn*, outsidechild_process.pyrunandpopen(with pipes) still start a child, a bare program name is found onPATH, and a missing program raisesFileNotFoundErrorA recorder on the fork path, run over the Desktop suite locally (macOS 15, Python 3.12, without the release-intent module): 56 forks came from engine modules on main, and none do with this change. That run had 1,659 passed and the two local-only failures explained in #2279; a third failure in it, a portal test that patched
subprocess.run, is fixed here.Not covered
webbrowser.openinauth/browser_pkce.pystarts its helper inside the standard library, once per sign-in, and still forks.multiprocessing, which forks in the same way. Removing tkinter from capture is the fix for that (release(capture): 1.4.0 #2286, then a Desktop pin raise).Release
A
fixcommit to shipped code, soscripts/prepare_release.pybumped the version to 0.30.5;check_release_intent.pyreports "Desktop release intent is consistent."