Bug 220023 - procstat -L only works with corefiles; documentation/code could be tweaked for usability/clarity
Summary: procstat -L only works with corefiles; documentation/code could be tweaked fo...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Bryan Drewery
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-16 00:43 UTC by Enji Cooper
Modified: 2019-01-21 21:39 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer freebsd_triage 2017-06-16 00:43:02 UTC
Using -a or specifying pids doesn't seem to work with procstat -L (it just prints out "unknown access method: 2"):

$ procstat -L -a 2>&1 | wc -l
     224
$ procstat -L -a 2>&1 | sort -u | wc -l
       1
$ procstat -L -a 2>&1 | tail -n 1
procstat: unknown access method: 2
$ uname -a
FreeBSD wkstn-fbsd-ngie 12.0-CURRENT FreeBSD 12.0-CURRENT #54 r319509+f79507d239c5(isilon-atf): Fri Jun  2 19:48:36 PDT 2017     ngie@wkstn-fbsd-ngie:/usr/obj/usr/src/sys/GENERIC-NODEBUG  amd64
$
Comment 1 Mark Johnston freebsd_committer freebsd_triage 2017-06-16 14:38:27 UTC
procstat -L shows information about a process' exit, so it's not expected to
work with live processes. We should update the man page and error message to
make this clear.
Comment 2 Enji Cooper freebsd_committer freebsd_triage 2017-06-27 01:52:52 UTC
Porting over internal bugzilla comments for context and taking the bug:

[reply] [-] Comment 2 Ngie "Hakuna Matata" Cooper 2017-06-26 18:31:03 PDT

I'll just fix the documentation since it doesn't state that it should or
shouldn't do that, which is a bug.

[reply] [-] Comment 3 Conrad Meyer 2017-06-26 18:38:45 PDT

I mean, it does say that already:

     -L      Display LWP info for the process pertaining to its signal driven
             exit.
             ^^^^                                               ^^^^^^^^^^^^^

[reply] [-] Comment 4 Ngie "Hakuna Matata" Cooper 2017-06-26 18:51:08 PDT

(In reply to comment #3)
> I mean, it does say that already:
> 
>      -L      Display LWP info for the process pertaining to its signal driven
>              exit.
>              ^^^^                                               ^^^^^^^^^^^^^

It's implied, but in a bit of a roundabout way as you noted. Also, the synopsis
suggests that it should be able to take either a pid or a corefile. From
https://www.freebsd.org/cgi/man.cgi?query=procstat&apropos=0&sektion=0&manpath=FreeBSD+12-current&arch=default&format=html
:

...

     procstat [--libxo]	[-CHhn]	[-w interval]
	      [-b | -c | -e | -f | -i |	-j | -k	| -l | -L | -r | -s | -S | -t |	-v | -x]
	      [-a | pid	| core ...]

...

Furthermore, if it's only meant to work with a corefile, the error message I
reported in the upstream bug could be clarified by returning the error from
kvm_open2, or something similar to that.

With mjohnston clarifying the use upstream and after reviewing things a bit
more, this is a Trivial item and not a Normal item.

What triggered this bug was the fact that I was trying to write tests/manually
test out the functionality, and because the documentation wasn't 100% clear, I
filed this bug and committed a few changes upstream to try and help clarify the
feature as best I could. This was one of the areas that wasn't clear to me that
I figured warranted more discussion.
Comment 3 commit-hook freebsd_committer freebsd_triage 2017-06-27 08:18:41 UTC
A commit references this bug:

Author: ngie
Date: Tue Jun 27 08:18:08 UTC 2017
New revision: 320399
URL: https://svnweb.freebsd.org/changeset/base/320399

Log:
  procstat_getptlwpinfo(..): clarify the fact that KVM/SYSCTL support
  isn't supported

  This will make the error message reported in bug 220023 a bit more
  intuitive for end-users that don't have access to the source code to
  decode the procstat->type argument.

  MFC after:	1 month
  MFC with:	r316286
  PR:		220023

Changes:
  head/lib/libprocstat/libprocstat.c
Comment 4 Enji Cooper freebsd_committer freebsd_triage 2017-07-20 05:45:15 UTC
------------------------------------------------------------------------
r321283 | ngie | 2017-07-19 22:43:48 -0700 (Wed, 19 Jul 2017) | 7 lines

procstat(8): clarify program usage

- Visualize mutually exclusive options and their corresponding
  arguments.
- Try to make the subtleties that are expressed in the code, and
  potentially in the manpages, more apparent.
Comment 5 Enji Cooper freebsd_committer freebsd_triage 2017-11-05 20:12:54 UTC
I think bdrewery backported the changes. If not, please let me know.
Comment 6 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-01-21 21:39:39 UTC
Bryan, does this still require MFC or the PR can be closed?

Thank