-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix login-shell probe cleanup #2124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
steipete
merged 4 commits into
steipete:main
from
anagnorisis2peripeteia:codex/fix-path-probe-timeout-descendants
Jul 14, 2026
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1d480a5
Fix login-shell probe cleanup
anagnorisis2peripeteia ffe0972
fix: harden login PATH probe cleanup
steipete 9c21ad7
Merge remote-tracking branch 'origin/main' into codex/pr-2124
steipete bc40e4b
fix: restore atomic Linux probe pipes
steipete File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import Testing | ||
| @testable import CodexBarCore | ||
|
|
||
| struct CodexExecutableResolverTests { | ||
| @Test | ||
| func `explicit override skips login path capture`() { | ||
| let resolved = resolveCodexExecutableForRPC( | ||
| environment: ["CODEX_CLI_PATH": "/usr/bin/true"], | ||
| executable: "codex", | ||
| captureLoginPATH: { | ||
| Issue.record("Explicit Codex override should not capture a login-shell PATH") | ||
| return nil | ||
| }) | ||
|
|
||
| #expect(resolved == "/usr/bin/true") | ||
| } | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| #if canImport(Darwin) | ||
| import Darwin | ||
| #else | ||
| import Glibc | ||
| #endif | ||
| import Foundation | ||
| import Testing | ||
| @testable import CodexBarCore | ||
|
|
||
| struct ShellCommandLocatorProcessTests { | ||
| @Test | ||
| func `shell runner terminates session escaped partial output holders after timeout`() throws { | ||
| let pidFile = FileManager.default.temporaryDirectory | ||
| .appendingPathComponent("codexbar-shell-runner-timeout-\(UUID().uuidString)") | ||
| .path | ||
| let stdoutPIDFile = "\(pidFile).stdout" | ||
| let stderrPIDFile = "\(pidFile).stderr" | ||
| let script = """ | ||
| import os | ||
| import signal | ||
| import sys | ||
| import time | ||
|
|
||
| for stream, suffix in ((1, ".stdout"), (2, ".stderr")): | ||
| child = os.fork() | ||
| if child == 0: | ||
| os.setsid() | ||
| signal.signal(signal.SIGHUP, signal.SIG_IGN) | ||
| signal.signal(signal.SIGTERM, signal.SIG_IGN) | ||
| os.close(2 if stream == 1 else 1) | ||
| with open(sys.argv[1] + suffix, "w") as handle: | ||
| handle.write(str(os.getpid())) | ||
| while True: | ||
| time.sleep(1) | ||
|
|
||
| while not all(os.path.exists(sys.argv[1] + suffix) for suffix in (".stdout", ".stderr")): | ||
| time.sleep(0.01) | ||
| time.sleep(1000) | ||
| """ | ||
|
|
||
| let start = Date() | ||
| let data = ShellCommandLocator.test_runShellCommand( | ||
| shell: "/usr/bin/python3", | ||
| arguments: ["-c", script, pidFile], | ||
| timeout: 0.2) | ||
| let elapsed = Date().timeIntervalSince(start) | ||
|
|
||
| let pids = try [stdoutPIDFile, stderrPIDFile].map { file in | ||
| let pidText = try String(contentsOfFile: file, encoding: .utf8) | ||
| .trimmingCharacters(in: .whitespacesAndNewlines) | ||
| return try #require(pid_t(pidText)) | ||
| } | ||
| defer { | ||
| for pid in pids { | ||
| kill(pid, SIGKILL) | ||
| } | ||
| for file in [stdoutPIDFile, stderrPIDFile] { | ||
| try? FileManager.default.removeItem(atPath: file) | ||
| } | ||
| } | ||
|
|
||
| #expect(data == nil) | ||
| #expect(elapsed < 3.0, "Timed-out PATH probes should remain bounded") | ||
| for pid in pids { | ||
| #expect(kill(pid, 0) != 0) | ||
| } | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
CODEX_CLI_PATHpoints at an executable Codex shim installed by npm/fnm/mise and the app or CLI starts with a minimal GUIPATH, this early return skipscurrentOrCapture, butCodexRPCClientlater launches the override through/usr/bin/envwithPathBuilder.effectivePATHbuilt from the uncaptured cache. The override itself is executable, yet its shebang such as/usr/bin/env nodecan no longer findnode, so explicit overrides that previously depended on the login-shell PATH fail to start. Consider capturing the login PATH for override launches without using it to locate the Codex binary, or pass the captured PATH through to the launch environment.Useful? React with 👍 / 👎.