Repository navigation
Fall back to the name and start time when MainModule is null [patch] - #215
Merged
Merged
Conversation
On Linux another user's /proc/<pid>/maps is unreadable, so MainModule comes back null instead of throwing Win32Exception. The null check made IsStoredProcessRunning answer "not running", so a second instance launched alongside one run by another user. A null module now takes the same fallback as access denied. The lookup goes through a seam so the path is testable. Fixes #214 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5qLcDVLnunDHexs7L
|
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
On Linux, .NET reads
MainModulefrom/proc/<pid>/maps. Another user can't read that file, soMainModulecomes backnullinstead of throwingWin32Exception. TheMainModule != nullclause inIsStoredProcessRunningthen answered "not running" without ever reaching the name-and-start-time fallback. A second instance could launch next to one run by another user, for example undersudo -E, or whenhidepidis set.null, the method takes the sameIsStoredProcessRunningByNamefallback that aWin32Exceptionalready takes.IsStoredProcessRunning(ProcessInfo, Func<Process, string?>), so that path can be tested without a second user account. The production overload passesp => p.MainModule?.FileName.Win32Exceptionpath is unchanged. A throw from the lookup is still caught by the existing handler.Tests
Four new tests run against a live helper process:
Win32Exception: running, same as today.dotnet test: 46 passed, 0 failed.Fixes #214
Generated by Claude Code