fix(opencode): AND lsof selection terms on macOS for cwd lookup#121
Merged
graykode merged 1 commit intoMay 14, 2026
Merged
Conversation
Without -a, lsof ORs the -p <pid> and -d cwd filters, so the output mixes the target pid's open files with cwd entries from every other process. The parser then grabs the first 'n...' line and can land on a different process's cwd, breaking the match against the OpenCode DB 'directory' column. Refs graykode#120
e2c2467 to
c4eb18c
Compare
graykode
approved these changes
May 14, 2026
Owner
graykode
left a comment
There was a problem hiding this comment.
Looks good. I verified the macOS lsof behavior locally: without -a, cwd entries from unrelated processes can be returned first, and with -a the lookup is scoped to the target PID's cwd. CI is green, and I don't see any blocking issues.
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.
Credit @Alexander-He for the diagnosis in #120.
Adds
-ato the lsof call inget_process_cwdso-p <pid>and-d cwdAND instead of OR. Without it, lsof returns cwd entries from unrelated processes too, and the parser grabs the firstn...line it sees, which can belong to a different pid. The OpenCode session match against the DBdirectorycolumn then fails and the session gets dropped.Linux path (
/proc/<pid>/cwd) is unaffected.Refs #120