Skip to content

feat(linux): tasksmack-helper reads other users' FD counts and I/O bytes for the Processes table (#2728) - #2938

Merged
mgradwohl merged 5 commits into
mainfrom
feat/helper-process-counters-2728
Oct 25, 2026
Merged

mgradwohl merged 5 commits into
mainfrom
feat/helper-process-counters-2728

Conversation

@mgradwohl

Copy link
Copy Markdown
Owner

Description

Part of #2728 (Linux helper coverage): with the helper held, the Processes table's Handles/FDs, I/O Read and I/O Write now fill in for other users' processes. Until now they stayed blank because /proc/[pid]/fd and /proc/[pid]/io refuse a non-root reader.

  • Protocol v4: a batched ReadProcessCounters request (39) and ProcessCountersResult (56). One round trip carries every target, capped at MAX_COUNTER_TARGETS (16384). Each entry has a flags byte (bit 1 = handle count read, bit 2 = I/O read); any other bit is refused.
  • Helper: the new ProcessCountersRead.h opens /proc/[pid], checks the start time, counts FDs with ProcFdScan, and parses io with ProcIoParser.h. That parser is now shared with LinuxProcessProbe, which drops its own copy. A target that has gone or been reused is left out of the reply.
  • Mapping: Readers::processCounters / handleProcessCounters. A helper without the reader answers ErrorReply. A reader that throws or finds nothing leaves out just that target.
  • Probe: BrokeredProcessProbe::enumerate() sends one callIfIdle batch (1 s timeout), and only for processes whose counts were refused. It only asks a helper that is already running, so it never prompts. After an ErrorReply (an older helper) it stops asking.
  • Windows: the pipe server classifies the new request as a read (its static_assert count is now 13). Windows doesn't serve it yet.
  • Other updates: fuzz corpus moved to v4 with two new seeds and an updated dict; tools/helper-handshake.py knows v4's Hello; docs updated in tasksmack.md and the FAQ.

PR Size

🔴 Large (~610 added / 76 removed across 42 files). Most of it is tests, the 20 regenerated one-byte-version corpus seeds, and the protocol's encode/decode boilerplate. The behavior change is the helper reader plus the probe's single batch.

Type of Change

  • New feature (non-breaking change that adds functionality)

Checklist

  • I have read the CONTRIBUTING guidelines
  • My code follows the project's coding standards
  • I have run clang-tidy and addressed any warnings
  • I have run clang-format on my changes
  • I have run pre-commit run --all-files or installed pre-commit hooks
  • I have added tests that prove my fix/feature works
  • All new and existing tests pass
  • I have updated documentation as needed

Testing

cmake --build --preset debug -j 4
TASKSMACK_REQUIRE_DISPLAY=1 TASKSMACK_REQUIRE_SDBUS=1 xvfb-run -a env -u WAYLAND_DISPLAY ctest --preset debug -j 4   # all pass

New tests:

  • BrokerProtocolTest: round trip, target cap, and refused flag bits.
  • BrokerRequestMappingTest: no reader, a throw, nullopt.
  • BrokeredProcessActionsTest: the probe fills refused counters, and stops after an ErrorReply.
  • ProcessCountersReadTest and ProcIoParserTest.
  • PkexecBrokerTest.TheHelperReadsProcessCountersAndLeavesOutAStaleTarget: the real helper binary over its socketpair.

WSL's kernel has no task I/O accounting (/proc/self/io is missing). The I/O assertions therefore expect ioRead exactly when /proc/self/io exists, so they hold on both kinds of kernel.

Additional Notes

v0.10.0 work, so no backport. The rest of #2728's Linux list (network attribution, hidepid listing, service actions, the title bar's text) follows in separate PRs.

🤖 Generated with Claude Code

mgradwohl and others added 2 commits October 25, 2026 10:23
…tes for the Processes table (#2728)

Protocol v4 adds a batched ReadProcessCounters request: one round trip for
every process whose handle count or /proc/[pid]/io the probe was refused.
The helper checks each target's start time, counts /proc/[pid]/fd and parses
/proc/[pid]/io with the parser LinuxProcessProbe now shares
(ProcIoParser.h), leaving out a target that has gone or been reused.

BrokeredProcessProbe asks only while a helper session is already held
(callIfIdle, 1 s timeout), never prompts, and stops asking after an
ErrorReply from an older helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…2728)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mgradwohl mgradwohl added enhancement New feature or request linux testing Platform agent:WSL Owned by the Linux/WSL Claude session (bug-fix conveyor) labels Oct 25, 2026
@mgradwohl
mgradwohl enabled auto-merge (squash) October 25, 2026 15:24
@github-actions github-actions Bot added documentation Improvements or additions to documentation windows tooling Developer tooling, CI, editor config, and automation labels Oct 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

… read (#2728)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mgradwohl
mgradwohl disabled auto-merge October 25, 2026 19:31
@mgradwohl
mgradwohl enabled auto-merge (squash) October 25, 2026 19:31
mgradwohl and others added 2 commits October 25, 2026 16:28
…ing seccomp filter (#2728, #2752)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:WSL Owned by the Linux/WSL Claude session (bug-fix conveyor) documentation Improvements or additions to documentation enhancement New feature or request linux Platform testing tooling Developer tooling, CI, editor config, and automation windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant