Skip to content

Delete the three-space branch from the ps parser - #806

Merged
SimonCropp merged 1 commit into
mainfrom
fix-ps-parse-three-space-branch
Aug 22, 2026
Merged

Delete the three-space branch from the ps parser#806
SimonCropp merged 1 commit into
mainfrom
fix-ps-parse-three-space-branch

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

ps -o pid,command has exactly one separator, so everything after the first
space is the command. The branch looking for a run of three spaces is left over
from a format that also carried TIME, and it was wrong in two ways at once.

It sliced timeAndCommandString by firstSpace - the PID's digit count, which is
not an index into that string at all - and then applied the index it found to
the unsliced span. So a command containing three consecutive spaces was
truncated to whatever followed them, and a seven digit PID with a short command
indexed past the end and threw ArgumentOutOfRangeException.

That throw comes out of ProcessCleanup's static constructor, so it is not one
bad line skipped: it is every launch and every kill in the process, permanently.

Two tests, both failing before this: a command with a run of spaces in it, and a
long PID with a short command.

`ps -o pid,command` has exactly one separator, so everything after the first
space is the command. The branch looking for a run of three spaces is left over
from a format that also carried TIME, and it was wrong in two ways at once.

It sliced timeAndCommandString by firstSpace - the PID's digit count, which is
not an index into that string at all - and then applied the index it found to
the unsliced span. So a command containing three consecutive spaces was
truncated to whatever followed them, and a seven digit PID with a short command
indexed past the end and threw ArgumentOutOfRangeException.

That throw comes out of ProcessCleanup's static constructor, so it is not one
bad line skipped: it is every launch and every kill in the process, permanently.

Two tests, both failing before this: a command with a run of spaces in it, and a
long PID with a short command.
@SimonCropp SimonCropp added this to the 20.0.0 milestone Aug 22, 2026
@SimonCropp
SimonCropp merged commit 7b7361f into main Aug 22, 2026
10 checks passed
@SimonCropp
SimonCropp deleted the fix-ps-parse-three-space-branch branch August 22, 2026 03:25
This was referenced Aug 26, 2026
This was referenced Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant