Home | History | Annotate | Download | only in ps
History log of /src/bin/ps/print.c
RevisionDateAuthorComments
 1.138  26-Jan-2022  andvar remove double t from targeted, add missing r to arbitrary
And fix few more typos along the way in comments and man pages.
 1.137  14-Sep-2021  christos use emalloc and friends, add ktrace flag printing.
 1.136  14-Sep-2021  christos Provide symbolic printing of some keywords by capitalizing them.
 1.135  17-Apr-2021  maya Remove SCCS workaround. No binary change.
 1.134  06-Apr-2021  christos - dedup code
- add a safe_strftime() to handle error cases
 1.133  06-Apr-2021  simonb Fix the column width calculation for the lstart column if an empty
column header is specified.

Fixes bug pointed out by Ted Spradley in
https://mail-index.netbsd.org/netbsd-users/2021/04/05/msg026808.html .
 1.132  19-Jun-2019  kamil branches: 1.132.2;
Add a fallback definition of LSDEAD in ps(1)

The symbol is no longer available in headers.

Requested by <mrg>
 1.131  18-Jun-2019  kamil Make LSDEAD usage conditional

LSDEAD is not used since NetBSD-5.0 and will be gone.

The same conditional usage is already in ps.c in the same program.
 1.130  19-Sep-2018  maxv Don't display l_wchan, either there is something in l_wmesg and we display
it, or there's nothing and we print "-".
 1.129  11-Apr-2018  christos branches: 1.129.2;
use EXIT_FAILURE instead of 1
 1.128  09-Dec-2017  kamil branches: 1.128.2;
ps: Rename local routine name from uname to usrname

This removes symbol name routine clash with libc's uname(3).
This allows to build ps(1) against LLVM Sanitizers.

Sponsored by <The NetBSD Foundation>
 1.127  12-Dec-2016  christos branches: 1.127.6;
Handle functions that use the offset from either kinfo_proc2/kinfo_lwp properly.
 1.126  02-Dec-2016  christos provide a tree like display with -d, from FreeBSD
 1.125  28-Nov-2016  rin Calculate CPU usage (pcpu) once per process if it is required. This change
significantly improves performance for slow machines when output is sorted
by pcpu.

ok martin
 1.124  28-Nov-2016  rin for donlist{,_sysctl}:
- obtain log_ccpu = log(ccpu) rather than ccpu itself
- use common default values and warn users appropriately when errors occur
ok martin
 1.123  15-Nov-2014  joerg branches: 1.123.2;
Use l_wmesg if the string is not empty. Don't bother checking l_name for
nullness.
 1.122  20-Apr-2014  dholland branches: 1.122.2;
Use an enum type for PRINTMODE vs. WIDTHMODE. Compiler output diffs have
been checked.
 1.121  15-Jan-2014  mlelstv branches: 1.121.2;
Add an LTIME column that prints lwp cputime.
 1.120  20-Mar-2012  matt branches: 1.120.2;
Use C89 function definitions
 1.119  13-Feb-2012  wiz Remove unused variable.
From cppcheck via Henning Petersen in PR 46002.
 1.118  13-Jun-2011  dholland branches: 1.118.2;
When converting from pages to kilobytes, cast the return value of
getpagesize() to size_t. For some reason getpagesize() is defined to
return int, and several of the page counts we get come back from the
kernel as int32_t; in LP64 without the cast the byte count will be
computed in a 32-bit value and for large processes will overflow and
become negative... and then remain negative when divided by 1024 to
convert to kilobytes.

Fixes a problem I hit the other day where I saw negative RSS, which
turns out also to be PR 40642.

Note: other logic in here will break down when we first get >2TB
processes... and int32 page counts will break on >8TB processes. But
hopefully we won't see any of that for a few years yet.
 1.117  22-Jan-2011  christos branches: 1.117.2;
fix previous.
 1.116  22-Jan-2011  christos Make printing of lwp flags similar to the process one, identifying (O)nproc
(K)ernel threads and scheduler (a)ctivations.
 1.115  28-Jul-2010  njoly branches: 1.115.2;
Do not check pcpu value against 100.0 but rather 99.95, to properly
deal with value rounding. From apb@.
 1.114  27-Jul-2010  njoly Make %cpu drop the decimal part when reaching 100%, to stay in the 5
expected columns.
 1.113  31-May-2010  rmind Fix ps(1) and top(1) to show reasonable CPU numbers i.e. cpu_index() provided
by the kernel, instead of CPU order number, which is generally random.
 1.112  21-Oct-2009  rmind Remove uarea swap-out functionality:

- Addresses the issue described in PR/38828.
- Some simplification in threading and sleepq subsystems.
- Eliminates pmap_collect() and, as a side note, allows pmap optimisations.
- Eliminates XS_CTL_DATA_ONSTACK in scsipi code.
- Avoids few scans on LWP list and thus potentially long holds of proc_lock.
- Cuts ~1.5k lines of code. Reduces amd64 kernel size by ~4k.
- Removes __SWAP_BROKEN cases.

Tested on x86, mips, acorn32 (thanks <mpumford>) and partly tested on
acorn26 (thanks to <bjh21>).

Discussed on <tech-kern>, reviewed by <ad>.
 1.111  29-Mar-2009  mrg - add new RLIMIT_AS (aka RLIMIT_VMEM) resource that limits the total
address space available to processes. this limit exists in most other
modern unix variants, and like most of them, our defaults are unlimited.
remove the old mmap / rlimit.datasize hack.

- adds the VMCMD_STACK flag to all the stack-creation vmcmd callers.
it is currently unused, but was added a few years ago.

- add a pair of new process size values to kinfo_proc2{}. one is the
total size of the process memory map, and the other is the total size
adjusted for unused stack space (since most processes have a lot of
this...)

- patch sh, and csh to notice RLIMIT_AS. (in some cases, the alias
RLIMIT_VMEM was already present and used if availble.)

- patch ps, top and systat to notice the new k_vm_vsize member of
kinfo_proc2{}.

- update irix, svr4, svr4_32, linux and osf1 emulations to support
this information. (freebsd could be done, but that it's best left
as part of the full-update of compat/freebsd.)


this addresses PR 7897. it also gives correct memory usage values,
which have never been entirely correct (since mmap), and have been
very incorrect since jemalloc() was enabled.

tested on i386 and sparc64, build tested on several other platforms.

thanks to many folks for feedback and testing but most espcially
chuq and yamt for critical suggestions that lead to this patch not
having a special ugliness i wasn't happy with anyway :-)
 1.110  14-Feb-2009  lukem fix -Wsign-compare issues
 1.109  03-Feb-2009  drochner branches: 1.109.2;
make sure the table stays aligned even if no groups are to be displayed
with the "groupnames" option
 1.108  03-Feb-2009  drochner make sure the table stays aligned even if no groups are to be displayed
with the "groups" option
 1.107  28-Dec-2008  christos fix dev_t 64 bit issues.
 1.106  19-Oct-2008  christos branches: 1.106.2;
Use 'O' for LSONPROC like solaris instead of bundling LSIDL, LSRUN, LSONPROC
to 'R'
 1.105  28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.104  10-Feb-2008  christos branches: 1.104.4;
Add a CPUID keyword; idea and some of the code from Anon Ymous
 1.103  31-Dec-2007  ad Remove systrace. Ok core@.
 1.102  06-Nov-2007  ad Kill another use of PZERO.
 1.101  01-Sep-2007  yamt add a keyword "lname", to print l_name.
 1.100  28-Jul-2007  dsl branches: 1.100.4; 1.100.6;
Don't call P_ZOMBIE(struct kinfo_proc2), it's p_stat field contains
lwp states, not process states!
Since the times are filled with zeros for zombie processes the check
before assuming teh process time is zero is moot - delete it.
Fix the other chact to test the p_realstat.
Fixer PR kern/36295
 1.99  17-Feb-2007  pavel Revert the changes done after newlock2 merge, except for the removal of
the now unused LSDEAD state. The current kernel headers are now
source-compatible with pre-newlock2 kernel headers again.

Approved by Andrew Doran.
 1.98  10-Feb-2007  ad Further changes to use compat process flags mapped by sysctl. To be
revisited soon.
 1.97  09-Feb-2007  ad Sync with kernel changes introduced by merging the newlock2 branch.
 1.96  29-Oct-2006  christos branches: 1.96.2; 1.96.4;
Add support for printing the emulation of the process.
 1.95  02-Oct-2006  apb * When all columns are given null customised headers, the blank header
line is not printed at all. This is specified in P1003.1-2004
(SUSv3), and is useful.

* Customised headers may contain embedded space, commas and equals
signs. To specify multiple customised headers, use multiple -o or -O
options. This is specified (for "-o", not for "-O") in P1003.1-2004
(SUSv3), and is useful.

* When a column is given a null (blank) customised header, it keeps its
default minimum width. This is specified in P1003.1-2004 (SUSv3), and
seems harmless.

* Fix a bug that made it impossible to print the same keyword multiple
times, with different customised headers each time. (Previously, the
last customised header was used for all instances of the keyword.)

* Make the behaviour of "-O" more useful. The first -O option adds
the default keywords only if there have not yet been any formatting
options, and multiple -O options now insert their keywords in adjacent
positions. Now {ps -j -O %cpu} is like {ps -j} with one extra column;
Previously, it would have had all the columns implied by "-j", plus
all the default columns, plus the extra column specified by "-O".

* Convert from home-grown linked lists to SIMPLEQ lists.

Discussed in tech-userlevel.
 1.94  27-Jun-2005  christos Add some more const so that this compiles again.
 1.93  26-Jun-2005  christos sprinkle a little const, and now everything compiles with WARNS=3
 1.92  07-Jun-2005  he Appease -Wuninitialized by initializing val and uval to 0.
Marked with XXXGCC for hpcarm (found while building for it).

Reviewed (in a slightly different form) by lukem.
 1.91  16-Nov-2004  christos print TTY instead of TT, one question mark instead of two and always the
full tty name.
 1.90  23-Apr-2004  simonb s/the the/the/ (only in sources that aren't regularly imported from
elsewhere).
 1.89  27-Mar-2004  simonb Gah, fix uninitialised variable with the "etime" change. _Never_ be
happy with something and then edit a single line before committing
without retesting...
 1.88  27-Mar-2004  simonb Add support for the POSIX.2 "args" and "comm" keywords. "args" is just
an alias for "command", and "comm" shows just argv[0] and not the whole
argument list.

Fix for part of PR standards/11224.
 1.87  27-Mar-2004  simonb Add support for the POSIX.2 "etime" keyword - shows the elapsed time
since the process was started. Fix a couple of style nits as well.

Fix for part of PR standards/11224.
 1.86  27-Mar-2004  simonb #define<TAB>
 1.85  27-Mar-2004  simonb Use some constants from <tzfile.h>.
 1.84  27-Mar-2004  simonb Wrap some long lines.
Consisently use (void) in front of printf(...);
A few more white-space nits.
 1.83  27-Mar-2004  simonb Fix grammar in a comment.
 1.82  27-Mar-2004  simonb KNF, ANSFify, de-__P, unC++ify, white space nits.
 1.81  24-Feb-2004  wiz Spell interrupt with two rs. From Peter Postma.
 1.80  11-Jan-2004  jdolecek g/c SDEAD
 1.79  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.
 1.78  06-Mar-2003  dsl - add keywords for utime, stime and ctime (output sss.ssssss if small)
- fiddle with keyword table - mainly to keep width under 80 cols
- add -k keylist so sort output
- don't use logs to work out field width, get -MAXINT right
- user defined headers can be 1 char (actually they can be zero length)
so ?? in tty column isn't guaranteed to be wider than header
- remove some long long casts (compiles on sparc64 still)
- use kvm_openfiles(NULL, NULL, NULL, KVN_NO_FILES, ..) unless core file
specified,
(approved by christos)
 1.77  01-Mar-2003  atatat Add p_svuid and p_svgid to kinfo_proc2. Populate them in the kernel
and in libkvm. Then teach ps how to show them to you.

Also, teach ps how to show the names for all the uids, the rest of the
group numbers, and the "group access list".
 1.76  18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.75  06-Jan-2003  wiz interrupt with two rs.
 1.74  19-Jun-2002  jdolecek g/c procfs fallback code, it's redundant now that we use sysctl to get
process info
 1.73  17-Jun-2002  christos Document some missing flags and add systrace(1) 'x' flag.
 1.72  24-Apr-2002  nathanw Since kinfo_proc2 has many values that are 64-bit, ps needs to know
that they're 64-bit, and grab them out of memory appropriately. Otherwise,
big-endian systems get the wrong end of the 64-bit value and lose.

Keywords affected: inblk, majflt, minflt, msgrcv, msgsnd, nivcsw, nsigs,
nswap, nvcsw, and oublk.
 1.71  21-Feb-2002  martin branches: 1.71.2;
Use int32_t for temporary variables (instead of long), that is the same
type as we get the data passed from the kernel. This avoids (missing)
sign extension bugs on LP64 systems and partly takes care of PR 15677.

We now print this values as negative seconds - still wrong, but that
probably is due to the simple way this values are acumulated in the
scheduler, causing negative times when ntpd steps time backwards.
 1.70  21-Jan-2002  jdolecek started(): don't assume that the field width is correct and recompute
it as needed

This fixes bogus output for cases like `ps -ao start=xx`, as reported by
Martin Macok of Undeground.cz on current-users@netbsd.org.
 1.69  24-Aug-2001  lukem fix comment: "[]" are [square] brackets, "<>" are angle brackets
 1.68  24-Aug-2001  enami Print commands within angled brackets only if they are system processes.
Print other commands, like cc, cpp and as, within parentheres.
 1.67  07-Aug-2001  christos Print system processes/kernel threads as [kprocname] as top(1) does.
 1.66  14-Jul-2001  matt Retrieve maxslp & uspace from kernel instead of using defines. Needed for
shared arm code.
 1.65  15-Jan-2001  christos clarify things a bit more (from hubertf)
 1.64  15-Jan-2001  christos Really explain what parenthesized names mean and why we parenthesize names!
 1.63  15-Jan-2001  hubertf Document the meaning of commands shown in parantheses.

Patches submitted by Jeremy C. Reed <reed@reedmedia.net> in PR 11930.
 1.62  09-Jan-2001  itojun KPTR/KPTR24 are using u_int64_t. commented by minoura
 1.61  08-Jan-2001  itojun redo previous (simplify KPTR)
 1.60  08-Jan-2001  itojun backout previous; did not compile on non-alpha
 1.59  08-Jan-2001  itojun simplify KPTR processing.
 1.58  08-Jan-2001  itojun address PR 11653. checked on alpha.
XXX supports 32bit and 64bit pointers only
 1.57  23-Oct-2000  simonb Add a K flag to the state information - K is for kernel thread or system
process (ie, P_SYSTEM set in p_flag). The L flag (locked in core) is
only used for non-P_SYSTEM processes.
 1.56  29-Jun-2000  mrg remove include of <vm/vm.h>
 1.55  08-Jun-2000  simonb branches: 1.55.2;
Fix handling of "ps U<user>" where <user> ended it 't' - now if the
first argument doesn't start with a '-' and ends in 't', the 't' only
gets converted to a 'T' (for listing processes on the current tty)
if it doesn't contain any other command line option characters that
take an argument. Problem noticed by ITOH Yasufumi on tech-userlevel.

If the 'start' format was the last column, the width wouldn't be set
and started() output a zero length string instead of a string the right
length - fix header width calculations so the the last column is handled
the same all others. This only showed up for 'start' because started()
knew that the column header is the same width and the field itself...

Update copyrights.
 1.54  08-Jun-2000  simonb Fix back-to-front assignment in tname() which meant that the column
width would never autosize past the header ("TT") width. Problem
noticed by Geoff Wing.
 1.53  07-Jun-2000  simonb Calculate field widths on the fly so that all columns line up nicely
and make more effective use of screen real estate when some columns
(eg USER and VSZ) didn't need the full default width.
 1.52  02-Jun-2000  simonb G/C evar() - now that everything is in the one structure it was exactly
the same as pvar().
 1.51  26-May-2000  simonb branches: 1.51.2;
Use new sysctl/kvm interfaces. This will stop the "proc size mismatch"
errors when internal kernel structures change size. Also remove
the sgid bit - all live kernel data is accessed through the sysctl
interface.
 1.50  26-May-2000  thorpej Handle SONPROC state.
 1.49  05-Dec-1999  fredb Fix CL* purge fallout.
 1.48  03-Dec-1999  simonb Since we have an "extern.h", put all external variable declarations in
that file and not sprinkled around various .c files.
 1.47  03-Dec-1999  simonb "ps -e" only shows the environment for the processes owned by the
current user id or all process if run by root.

Fixes PR security/5967 from Todd Vierling.
 1.46  15-Oct-1999  jdolecek command(): don't start using procfs_getargv() instead of kvm_getargv()
just because the latter returned a NULL - that may normally happen,
when the process is, for example, a kernel thread

procfs_getargv(): if the name is brackened in '(' and ')', just
return NULL immediately - the code in command() will DTRT
and the output will be same for procfs- and kvm- based lookup
in all cases
 1.45  15-Oct-1999  jdolecek When using the procfs for extracting process information, extract
also process start time, process arguments and session leadership status.

The procfs fallback is also used when kvm_openfiles() completely fails
(e.g. when /dev/mem is not readable).

Solves PR 7772, though the final implementation is different.
 1.44  11-Oct-1999  mrg skip "dty" just like we skip "tty", otherwise we just get "dt" in ps output for all dty's
 1.43  23-Jul-1999  veego branches: 1.43.2;
According to the previous commit the new process state should be SDEAD and
not SDYING, so s/SDYING/SDEAD/.
 1.42  22-Jul-1999  thorpej Update for SDEAD.
 1.41  03-May-1999  mrg limit session to 6 chars. from Geoff Wing <gcw@pobox.com> and fixes his PR#7506
 1.40  16-Apr-1999  christos Add support for printing wide sigset_t properly.
 1.39  28-Jul-1998  mycroft branches: 1.39.2;
Look for the formats used by setproctitle(3) and login shells, and avoiding
outputting the redundant `(comm)'.
 1.38  27-Jul-1998  mycroft __AUDIT__ cleanup.
 1.37  01-Apr-1998  kleink Need <time.h> for localtime(), time() and strftime() prototypes.
 1.36  06-Feb-1998  mrg remove old OLD BSD VM code.
 1.35  05-Feb-1998  gwr Begone KERNBASE! (Just print kernel pointers as-is.)
 1.34  03-Aug-1997  mikel use %c not %C for lstart; from tetsuya@secom-sis.co.jp via OpenBSD
 1.33  20-Jul-1997  christos Fix compiler warnings
Add WARNS=1
 1.32  19-Mar-1997  mycroft DTRT if e_wmesg is not NUL-terminated.
 1.31  19-Mar-1997  mycroft DTRT if e_login is not NUL-terminated.
 1.30  02-Oct-1996  ws Fix p_nice vs. NZERO code.
Remove some unnecessary casts.
Remove an unused time format field.
 1.29  15-Aug-1996  explorer return 0.0 cpu usage for zombies. closes pr bin/2693. Perhaps this should
be fixed in exit, so p->p_pctcpu is cleared when the process exits.
 1.28  13-Jul-1996  explorer include <pwd.h> for one function (user_from_uid) and correct one
%*d -> %*ld in a format string. (yes, trying to find the problem with
ps wwwwwwwww1 and core dump, and might as well clean up while here)
 1.27  29-Sep-1995  cgd add code to convert from INT32 and UINT32 to native types.
 1.26  15-Aug-1995  cgd Kenneth Stailey pointed out that his previous fix was incorrect. RE and SL
should be bounded at 127, not 99.
 1.25  14-Aug-1995  cgd as suggested in PR 1347, by Kenneth Stailey, make "RE" and "SL" fields
show up as two digits, max, displaying "99" if > 99. allow any field with
an unsigned value to be specified as printing that way (though right now
it's only used for RE and SL, which are both unsigned longs). This fix
is substantially different than that suggested in the PR.
 1.24  07-Jun-1995  cgd typeof(timeval.ts_sec) != time_t
 1.23  25-May-1995  mycroft If there is another field after the command, fill in the command field with
blanks.
 1.22  21-May-1995  mycroft Split out some helper functions again.
 1.21  18-May-1995  mycroft Create and strvis(3) the argument and environment lists only as needed.
Do not keep extra copies around.
 1.20  18-May-1995  mycroft Avoid an extra (gratuitous) pass through strvis(3).
 1.19  08-May-1995  cgd add the ability to understand and print INT and UINT-sized variables.
 1.18  21-Mar-1995  cgd convert to new RCS id conventions.
 1.17  23-Dec-1994  cgd be careful with addresses.
 1.16  04-Dec-1994  cgd from James Jegers <jimj@miller.cs.uwm.edu>: quiet -Wall, and squelch
some of the worst style errors.
 1.15  03-Nov-1994  deraadt kill UPAGES
 1.14  15-Sep-1994  deraadt NBPG -> getpagesize()
 1.13  16-Jun-1994  pk No more P_NOSWAP/P_PHYSIO.
 1.12  09-May-1994  cgd clean up import
 1.11  05-May-1994  cgd struct element foo
 1.10  05-May-1994  cgd update for changed flags
 1.9  14-Aug-1993  mycroft Fix test for zombie process.
 1.8  01-Aug-1993  mycroft Add RCS identifiers.
 1.7  18-Jun-1993  cgd use strvis on the arguments and environment, so we don't end up in
sed and/or xterm-title-changing hell.
 1.6  02-Jun-1993  cgd make ps do something more sensible with zombie processes
 1.5  01-Jun-1993  cgd fix more-or-less-uninitialized variable...
 1.4  01-Jun-1993  cgd add support and documentation for the 'e' option, to print out
the process environment.
 1.3  23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2  22-Mar-1993  cgd added rcs ids to all files
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2  09-May-1994  cgd new ps, to match libkvm
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.39.2.2  08-Nov-1999  cgd pull up revs 1.45-1.46 from trunk (requested by jdolecek):
When using the procfs for extracting process information, extract process
start time, arguments, and session leadership status. Also, fall back to
procfs when kvm_openfiles() completely fails (e.g. when /dev/mem is not
readable). Fixes PR#7772.
 1.39.2.1  12-Oct-1999  he Pull up revision 1.44 (requested by mrg):
Make various utilities skip "dty" as well as "tty" on terminals,
so that the actually used tty is visiable instead of just 'dt'.
 1.43.2.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.51.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.55.2.1  27-Jan-2001  jhawk Pull up revisions 1.63-1.65 (requested by hubertf):
Clarify meaning of COMMANDs printed in parentheses. Addresses PR11930.
 1.71.2.7  17-Jan-2003  thorpej Sync with HEAD.
 1.71.2.6  12-Nov-2002  nathanw Catch up to -current.
 1.71.2.5  26-Jul-2002  nathanw Print state letter 'U' for suspended LWPs.
Make sure to print '+' (controlling terminal) character last.
 1.71.2.4  24-Apr-2002  nathanw Parallel change to mainline: handle 64-bit values properly.
 1.71.2.3  24-Apr-2002  nathanw Note the presense of multiple LWPs or scheduler activations under "state".
Add a "lstate" that prints LWP-specific state and display it instead
of "state" under ps -s.
 1.71.2.2  23-Apr-2002  nathanw Add support for handling multi-LWP processes by selecting one LWP as
"representative" of the process.
Also add a -s option that prints a line for each LWP.
While I'm here, remove the /proc fallback code.
 1.71.2.1  21-Feb-2002  nathanw file print.c was added on branch nathanw_sa on 2002-04-23 20:41:12 +0000
 1.96.4.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.96.2.1  30-Jul-2007  liamjfoy Pull up following revision(s) (requested by dsl in ticket #798):
bin/ps/print.c: revision 1.100
Don't call P_ZOMBIE(struct kinfo_proc2), it's p_stat field contains
lwp states, not process states!
Since the times are filled with zeros for zombie processes the check
before assuming teh process time is zero is moot - delete it.
Fix the other chact to test the p_realstat.
Fixer PR kern/36295
 1.100.6.2  28-Jul-2007  dsl Don't call P_ZOMBIE(struct kinfo_proc2), it's p_stat field contains
lwp states, not process states!
Since the times are filled with zeros for zombie processes the check
before assuming teh process time is zero is moot - delete it.
Fix the other chact to test the p_realstat.
Fixer PR kern/36295
 1.100.6.1  28-Jul-2007  dsl file print.c was added on branch matt-mips64 on 2007-07-28 17:05:51 +0000
 1.100.4.3  23-Mar-2008  matt sync with HEAD
 1.100.4.2  09-Jan-2008  matt sync with HEAD
 1.100.4.1  06-Nov-2007  matt sync with HEAD
 1.104.4.1  18-May-2008  yamt sync with head.
 1.106.2.1  01-Apr-2009  snj Pull up following revision(s) (requested by mrg in ticket #622):
bin/csh/csh.1: revision 1.46
bin/csh/func.c: revision 1.37
bin/ps/print.c: revision 1.111
bin/ps/ps.c: revision 1.74
bin/sh/miscbltin.c: revision 1.38
bin/sh/sh.1: revision 1.92 via patch
external/bsd/top/dist/machine/m_netbsd.c: revision 1.7
lib/libkvm/kvm_proc.c: revision 1.82
sys/arch/mips/mips/cpu_exec.c: revision 1.55
sys/compat/darwin/darwin_exec.c: revision 1.57
sys/compat/ibcs2/ibcs2_exec.c: revision 1.73
sys/compat/irix/irix_resource.c: revision 1.15
sys/compat/linux/arch/amd64/linux_exec_machdep.c: revision 1.16
sys/compat/linux/arch/i386/linux_exec_machdep.c: revision 1.12
sys/compat/linux/common/linux_limit.h: revision 1.5
sys/compat/osf1/osf1_resource.c: revision 1.14
sys/compat/svr4/svr4_resource.c: revision 1.18
sys/compat/svr4_32/svr4_32_resource.c: revision 1.17
sys/kern/exec_subr.c: revision 1.62
sys/kern/init_sysctl.c: revision 1.160
sys/kern/kern_exec.c: revision 1.288
sys/kern/kern_resource.c: revision 1.151
sys/sys/param.h: patch
sys/sys/resource.h: revision 1.31
sys/sys/sysctl.h: revision 1.184
sys/uvm/uvm_extern.h: revision 1.153
sys/uvm/uvm_glue.c: revision 1.136
sys/uvm/uvm_mmap.c: revision 1.128
usr.bin/systat/ps.c: revision 1.32
- - add new RLIMIT_AS (aka RLIMIT_VMEM) resource that limits the total
address space available to processes. this limit exists in most other
modern unix variants, and like most of them, our defaults are unlimited.
remove the old mmap / rlimit.datasize hack.
- - adds the VMCMD_STACK flag to all the stack-creation vmcmd callers.
it is currently unused, but was added a few years ago.
- - add a pair of new process size values to kinfo_proc2{}. one is the
total size of the process memory map, and the other is the total size
adjusted for unused stack space (since most processes have a lot of
this...)
- - patch sh, and csh to notice RLIMIT_AS. (in some cases, the alias
RLIMIT_VMEM was already present and used if availble.)
- - patch ps, top and systat to notice the new k_vm_vsize member of
kinfo_proc2{}.
- - update irix, svr4, svr4_32, linux and osf1 emulations to support
this information. (freebsd could be done, but that it's best left
as part of the full-update of compat/freebsd.)
this addresses PR 7897. it also gives correct memory usage values,
which have never been entirely correct (since mmap), and have been
very incorrect since jemalloc() was enabled.
tested on i386 and sparc64, build tested on several other platforms.
thanks to many folks for feedback and testing but most espcially
chuq and yamt for critical suggestions that lead to this patch not
having a special ugliness i wasn't happy with anyway :-)
 1.109.2.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.115.2.1  08-Feb-2011  bouyer Sync with HEAD
 1.117.2.1  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.118.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.118.2.1  17-Apr-2012  yamt sync with head
 1.120.2.1  19-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.121.2.1  10-Aug-2014  tls Rebase.
 1.122.2.1  14-May-2015  snj Pull up following revision(s) (requested by joerg in ticket #758):
bin/ksh/Makefile: revision 1.31
bin/ps/print.c: revision 1.123
external/bsd/iscsi/dist/src/lib/parameters.c: revision 1.4
external/bsd/iscsi/dist/src/lib/target.c: revision 1.9
external/gpl2/lvm2/dist/lib/commands/toolcontext.c: revision 1.8
external/gpl2/lvm2/dist/lib/format1/import-export.c: revision 1.2
gnu/dist/texinfo/makeinfo/xml.c: revision 1.2
sbin/bioctl/bioctl.c: revision 1.16
usr.sbin/isdn/isdnd/msghdl.c: revision 1.12
Drop pointer checks that are always true.
--
Comment out impossible code.
--
Remove tautologic check.
--
Skip vendor if the string is empty.
Use l_wmesg if the string is not empty. Don't bother checking l_name for
nullness.
--
Array can't be null.
--
Show display if it is not empty.
--
Make cast warnings for clang non-fatal.
 1.123.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.127.6.1  06-Apr-2021  martin Pull up following revision(s) (requested by simonb in ticket #1669):

bin/ps/print.c: revision 1.133

Fix the column width calculation for the lstart column if an empty
column header is specified.

Fixes bug pointed out by Ted Spradley in
https://mail-index.netbsd.org/netbsd-users/2021/04/05/msg026808.html .
 1.128.2.2  30-Sep-2018  pgoyette Ssync with HEAD
 1.128.2.1  16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.129.2.4  21-Apr-2020  martin Ooops, restore accidently removed files from merge mishap
 1.129.2.3  21-Apr-2020  martin Sync with HEAD
 1.129.2.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.129.2.1  10-Jun-2019  christos Sync with HEAD
 1.132.2.1  06-Apr-2021  martin Pull up following revision(s) (requested by simonb in ticket #1244):

bin/ps/print.c: revision 1.133

Fix the column width calculation for the lstart column if an empty
column header is specified.

Fixes bug pointed out by Ted Spradley in
https://mail-index.netbsd.org/netbsd-users/2021/04/05/msg026808.html .

RSS XML Feed