Skip to content

WIP: procps P2b — pgrep/pkill/top/vmstat/watch/namei/killall (Refs #1127, #1462) - #1477

Merged
caomengxuan666 merged 3 commits into
mainfrom
fix/1127-p2b-procps
Oct 31, 2026
Merged

caomengxuan666 merged 3 commits into
mainfrom
fix/1127-p2b-procps

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Draft PR for the P2b procps cluster (deliver-and-done; do not merge from this PR without collector review).

Implements the missing procps-family surface oracle-source-first, per the contracts in procps-v4.0.4 (pgrep.c, vmstat.c, watch.c, top/top.c), util-linux 2.39.3 (namei.c), and the psmisc killall(1) contract:

  • pgrep/pkill: shared selection engine (src/commands/procps_select.h) mirroring select_procs() — selectors -u/-U/-G/-P/-s/-F/-L/-O/-A, -n/-o reductions with upstream tie rules, -v inversion, -w thread listing, pidfile validation, -SIGNAL spellings, upstream usage errors/exit codes, the >15-character pattern warning. One audit claim was falsified against the oracle testsuite (pgrep name matching is NOT anchored upstream; the existing unanchored search was already correct).
  • vmstat: full rewrite to the vmstat.c surface (report/-s/-d/-D/-p/-m, -S units, -t, -y, delay/count).
  • watch: procps option set; -c is --color (count moved to long-only --count), upstream exit semantics, -e/-g/-q, -x; one pinned unit test corrected to the upstream contract.
  • namei: -m/-o/-v/-x/-n/-Z/-l layered on the pinned namei 裸盘符根 /x 形态逐组件 GetFileAttributesW 误解析——盘符方言形态全链失败 #1237 dialect; missing component exits 1.
  • killall: -i/-l/-r/-s/-u/-v/-w/-y/-o + signal spellings.
  • top: fractional -d, procps -o fields with direction, -O, -E/-e scales, -1 per-CPU, real swap figures.
  • i18n: zh-CN companion PR in winuxcmd-i18n (catalog delta + VERSION 0.6.25); MANUAL_MESSAGES top help synced.

Cannot be built locally (MSVC-only repo, Linux VM) — CI (x64+arm64 build + ctest + differential) is the first gate. Full per-applet detail, oracle citations, and every unverified/approximated mapping are in REPORT.md on this branch's workdir copy (delivered with the cluster report).

Refs #1127
Refs #1462

…killall surface

Oracle-source-first pass over the procps family (contracts derived
from procps-v4.0.4 pgrep.c/vmstat.c/watch.c/top.c, util-linux 2.39.3
namei.c, and the psmisc killall man page contract):

- pgrep/pkill: full selector set (-u/-U/-G/-P/-s/-F/-L/-O/-A/-n/-o,
  -v and -w for pgrep, -e/-q for pkill, -SIGNAL spellings via a shared
  procps_select.h engine mirroring select_procs(); pidfile validation;
  upstream usage errors and exit codes (2), the >15-char pattern
  warning, pkill -c printing the matched count.
- vmstat: rewritten to the vmstat.c report (headers, since-boot row,
  delay/count, -y), -s sum_format, -d/-D disk modes, -p partition,
  -m header, -S unit conversion, -t timestamps, -f handled during
  option processing.
- watch: -c is --color (count moved to long-only --count), fractional
  -n with the 0.1s clamp and WATCH_INTERVAL, -e/-g/-q exit semantics,
  upstream exit codes (child status no longer propagated), -x exec
  mode, -d permanent highlighting, "Every %.1fs:" header.
- namei: -m/-o/-v/-x/-n/-Z and -l layered on the pinned #1237 dialect;
  junctions report as mount points; a missing component exits 1.
- killall: exact-name default kept, plus -i/-l/-r/-s/-u/-v/-w/-y/-o
  and -SIGNAL spellings; per-name "no process found" reporting.
- top: fractional -d, procps -o field names with +/- direction,
  -O field list, -E/-e memory scales, -1 per-CPU lines, real paging
  file swap figures, -p clashes with -u/-U; legacy long spellings kept
  as invisible aliases.
- utils: per-process account/group/session/creation-time/thread/image
  queries backing the selectors.
- i18n: MANUAL_MESSAGES top custom_help synced with the new text.
- tests: unit coverage for the new options in all seven applets;
  watch's pinned child-status expectation corrected to the upstream
  contract (status only propagates under -e).

Refs #1127
Refs #1462
…1 per-CPU lines

per_cpu_usages passed class 1 to NtQuerySystemInformation. Class 1 is
SystemProcessorInformation -- a single small record -- so the returned
byte count divided by sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)
yielded zero processors, the per-CPU vector came back empty, and the
header silently fell back to the aggregate %Cpu(s) line even with -1.
Class 8 is SystemProcessorPerformanceInformation, the per-logical-
processor array the function actually reads.

GNU contract: procps top's do_cpus prints one line per processor when
CPUs are not combined, labeled with the eachcpu format "%%Cp%c%-3d:"
(src/top/top_nls.c:517; loop in src/top/top.c do_cpus) -- i.e. %Cpu0,
%Cpu1, ... The unit pin top.top_single_cpu encodes exactly that and
was the one red test in the x64 ctest run (3518/3519 passed).

Refs #1127
@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 31, 2026 21:02
@caomengxuan666
caomengxuan666 merged commit 3c58e60 into main Oct 31, 2026
8 of 9 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/1127-p2b-procps branch November 2, 2026 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant