Skip to content

List every NetBSD thread with ps -s - #3817

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:netbsd-threads
Oct 17, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:netbsd-threads

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

NetBSD's ps prints one row per process unless it is given -s, and that row carries only the process's first LWP. So OSProcess.getThreadDetails() returned one thread per process, and OperatingSystem.getCurrentThread() found no row for any thread but the first, which left its details empty.

Both lookups now use a single command constant, NetBsdOSThread.PS_THREAD_COMMAND, which includes -s. Before, each built its own copy of the command.

Verified on NetBSD 10.1 aarch64 (cfarm428):

No new unit test: the parsing is unchanged; only the -s flag is new.

Summary by CodeRabbit

  • Bug Fixes
    • On NetBSD, process thread details now include all threads, and current-thread detection can find threads that were previously missed. This improves the completeness of thread information reported by the operating system APIs.

NetBSD's ps prints one row per process unless given -s, and that row
carries only the process's first LWP. getThreadDetails() therefore
returned a single thread per process, and getCurrentThread() found no
row for any thread but the first, so its details came back empty.

Both lookups now use one command constant, NetBsdOSThread.PS_THREAD_COMMAND,
which includes -s. Verified on NetBSD 10.1 aarch64 (cfarm428): pid 0 now
reports 211 threads, matching ps -s; the current thread has real state,
CPU time and context switches with JNA native and with FFM; the full
test suite passes.
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 210bb8d6-4a1b-417b-8297-6ca5635a8849
📥 Commits

Reviewing files that changed from the base of the PR and between 6da328d and 3353f8f.

📒 Files selected for processing: 3
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdOSThread.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 10
  • GitHub Check: Test JDK 25, NetBSD
  • GitHub Check: Test JDK 25, OpenIndiana
  • GitHub Check: Test JDK 25, OpenBSD
  • GitHub Check: Test JDK 25, FreeBSD
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 25, ubuntu-latest
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Lint (Spotless, Checkstyle)
  • GitHub Check: Lint (ForbiddenAPIs, Javadoc, SLF4J)
  • GitHub Check: Error Prone
🧰 Additional context used
📚 Code guidelines: 2
AGENTS.md — unknown
CONTRIBUTING.md — unknown
📓 Path-based instructions: 2
Source excerpt: **Banned APIs** (`config/forbidden-apis.txt` and friends, enforced by `forbiddenapis:check`): `oshi-common` may not reference `com.sun.jna.**`, `java.lang.foreign.**`, or any `System.load`/`loadLibrary`.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdOSThread.java
Applicability reference: AGENTS.md: # AGENTS.md Instructions for AI coding agents working in the OSHI repository.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • CHANGELOG.md
🔇 Additional comments: 3
oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdOSThread.java: 1

45-49: LGTM!

Also applies to: 81-81

oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdOSProcess.java: 1

284-284: LGTM!

CHANGELOG.md: 1

24-24: LGTM!

📝 Walkthrough

NetBSD thread enumeration now uses a shared ps command that includes -s. NetBsdOSProcess.getThreadDetails() uses this command, and NetBsdOSThread.psThreadCommand() returns it.

Changes: NetBSD thread enumeration

Layer / File(s) Summary
Shared thread command
oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdOSThread.java, oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdOSProcess.java, CHANGELOG.md
NetBsdOSThread defines and returns a ps command that includes -s. NetBsdOSProcess.getThreadDetails() uses the shared command. The changelog records the update.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 3353f

The shared command lists each LWP for the selected process, so the changed thread-enumeration paths have no identified merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding ps -s so NetBSD thread queries list every thread.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the threads in flight,
With ps -s, each comes to sight.
One shared command leads the way,
Through process lists, both night and day.
The rabbit hops, then rests in hay.

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.84%. Comparing base (6da328d) to head (3353f8f).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3817      +/-   ##
============================================
- Coverage     80.85%   80.84%   -0.02%     
- Complexity      648      671      +23     
============================================
  Files           725      725              
  Lines         26044    26045       +1     
  Branches       4422     4422              
============================================
- Hits          21058    21055       -3     
- Misses         2768     2770       +2     
- Partials       2218     2220       +2     
Flag Coverage Δ
freebsd 37.13% <0.00%> (-0.01%) ⬇️
linux 41.14% <0.00%> (-0.03%) ⬇️
macos 42.29% <0.00%> (-0.04%) ⬇️
netbsd 36.46% <100.00%> (+0.01%) ⬆️
openbsd 37.01% <0.00%> (-0.01%) ⬇️
solaris 38.30% <0.00%> (-0.01%) ⬇️
windows 48.57% <0.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbwiddis
dbwiddis merged commit 0b6b275 into oshi:master Oct 17, 2026
20 checks passed
@dbwiddis
dbwiddis deleted the netbsd-threads branch October 17, 2026 04:30
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