FreeBSD process listing results in "keyword not found" errors #1673
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.
While testing FreeBSD support in a separate PR, I noticed that some processes weren't getting listed. Debugging it further, I found that
ps(1)
was printing the following:$ uname -a FreeBSD freebsd 13.0-RELEASE FreeBSD 13.0-RELEASE #0 releng/13.0-n244733-ea31abc261f: Fri Apr 9 04:24:09 UTC 2021 root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 $ ps -awwxo state,pid,ppid,user,uid,group,gid,nlwp,pri,vsz,rss,etimes,systime,time,comm,majflt,minflt,nvscw,nivscw,args ps: nvscw: keyword not found ps: nivscw: keyword not found STAT PID PPID USER UID GROUP GID NLWP PRI VSZ RSS ELAPSED SYSTIME TIME COMMAND MAJFLT MINFLT COMMAND DLs 0 0 root 0 wheel 0 368 -16 0 5888 2667 0:10.32 0:10.32 kernel 0 0 [kernel] […] $
Despite the fact that those keywords are listed in the man page, they don't appear to work (at least not on FreeBSD 13.0).
Another problem I noticed was that the list of
ps(1)
keywords was duplicated in OSHI: once inFreeBsdOperatingSystem
and again inFreeBsdOSProcess
. The former used 20 arguments, including the brokennvscw
andnivscw
. The latter used 18 arguments, excludingnvscw
andnivscw
. Yet both passed the result of theps(1)
invocation toreeBsdOSProcess#updateAttributes(java.lang.String[])
, which seemed broken.I made the two classes consistent with each other by consolidating the list of
ps(1)
keywords into a single 18-element list that is shared by both classes. The list doesn't contain the problematic keywords. Yes, this means thatgetContextSwitches()
will always return 0, but this seems to have been broken even before this PR, and FreeBSD'sgetBytesRead()
andgetBytesWritten()
are also broken in this manner today, so I doubt this will be a big problem. And at least this fixes my original problem: now I can get a listing of all processes on the system. I tested this on FreeBSD 13.0 and it resolved my original issue.