Repository navigation
fix(updater): detect the running app after its executable is replaced - #1706
Merged
ilysenko merged 2 commits intoNov 21, 2026
Merged
Conversation
ilysenko
approved these changes
Nov 21, 2026
ilysenko
left a comment
Owner
There was a problem hiding this comment.
Thanks for the focused fix. Reusing install::strip_deleted_path_suffix keeps the liveness guard consistent with restart.rs, the change only makes the guard stricter, and the tests cover both the real kernel (deleted) link and the false-match cases. The failing package/Nix jobs came from the 26.1117 drift that #1708 fixed on main; I updated the branch and the full CI is green on the new head. Approving.
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.
Summary
liveness::is_app_runningis the guard that keeps the updater from installing or rolling back while ChatGPT Community is open. It checks each/proc/<pid>/exelink with a strict equality against/opt/codex-desktop/ChatGPT(updater/src/liveness.rs:34-39):When a package transaction replaces
/opt/codex-desktop/ChatGPTwhile the app is running, the running process keeps the old, now-unlinked image, and the kernel reports its link as/opt/codex-desktop/ChatGPT (deleted). That never equals the expected path, sois_app_runningreturnsfalsefor an app that is still open. This happens, for example, after installing a package by hand (apt install ./codex-desktop_*.deb,rpm -U,pacman -U) with the app open.All callers of the guard then act as if the app were closed:
rollback.rs:184:codex-update-manager rollbackgoes ahead and installs the rollback package over the running app instead of printing "Close it before rollback".app.rs:178/app.rs:694: a pending update goes straight to the privileged install instead of waiting for the app to exit.app.rs:934:diagnose --jsonreports"appRunning": false.The crate already handles this kernel suffix for its own binary:
restart.rs:17usesinstall::strip_deleted_path_suffix(&link_target).unwrap_or(link_target). This PR applies the same helper inliveness.rs, in a smallexe_link_matchesfunction. A link only matches if it is the expected path, or the expected path followed by exactly one(deleted). Other paths, other(deleted)paths and prefix collisions such asChatGPT-helper (deleted)still do not match.This is the liveness half of #1315, which was closed during the move to the official Linux package with an invitation to refresh it if still needed. The strict comparison is still on current
main(04840e9), so this is a refreshed, standalone version of that part. The read-aloud half of #1315 is not included.Affected formats/features: the updater only (
codex-update-manager), the same on every package format and architecture. No launcher, packaging or ASAR change.Validation
updater/src/liveness.rs:running_app_is_still_detected_after_its_executable_is_replacedcopies/bin/sleepto a tempChatGPT(through acpchild process, so the test runner never holds a writable descriptor for it, the same reason as fix(updater): prevent ETXTBSY in executable test fixtures #1588), starts it, unlinks it, checks that/proc/<pid>/exereally ends in(deleted), and assertsprocess_matchesstill finds the process.replaced_executable_of_another_path_is_not_mistaken_for_the_appcovers the exact path, the deleted path, a deleted path in another directory, aChatGPT-helper (deleted)prefix collision, and a doubled suffix.ubuntu-latestwith stable Rust 1.100.0 (the CI toolchain), using the same tests and the oldpath == expectedcomparison: both new tests fail (assertion failed: still_detectedandassertion failed: exe_link_matches(Path::new("/opt/codex-desktop/ChatGPT (deleted)"), expected)), and the other 131 tests pass. The(deleted)assertion beforestill_detectedpasses there, so the kernel behavior is confirmed on a real Linux runner.cargo test -p codex-update-managerpasses all 133 tests, andcargo clippy -p codex-update-manager -- -D warnings(the CI command), the same with--all-targets, andcargo fmt -p codex-update-manager --checkare all clean.ChatGPT(deleted)without a space, bare(deleted), empty, an unrelated binary). Only/opt/codex-desktop/ChatGPT (deleted)changes, from no match to match.cargo fmt -p codex-update-manager --checkis clean. I could not build the updater locally because the host is macOS (notify_rust::Notification::hintis Linux-only), so the Linux results above come from GitHub Actions on my fork.rustandsource-and-nodepass.signed-baseline,dock-icon-feature-alone,official-linux-gateandnix-buildfail for a reason unrelated to this change. The official package moved to26.1117.41037, sofeature:ui-tweaks:reasoning-effort-labels-englishreportsExpected one Simplified Chinese locale loader, found 0, and the Nix package pin is out of date. Other open PRs fail the same way, and Fix three Linux feature patches for signed 26.1117 #1705 addresses that drift. This PR only changesupdater/src/liveness.rs.rollback). The test above reproduces the same kernel state with a stand-in binary.Checklist
rustandsource-and-nodepass here. The package-build jobs fail because of the unrelated 26.1117 drift described above.)🤖 Generated with Claude Code