Commit Graph

138 Commits

Author SHA1 Message Date
andvar 7c674e8e6e remove double t from targeted, add missing r to arbitrary
And fix few more typos along the way in comments and man pages.
2022-01-26 11:48:53 +00:00
christos 9dc307c463 use emalloc and friends, add ktrace flag printing. 2021-09-14 22:01:17 +00:00
christos c879b655cb Provide symbolic printing of some keywords by capitalizing them. 2021-09-14 17:09:18 +00:00
maya 266b57cd8b Remove SCCS workaround. No binary change. 2021-04-17 08:35:33 +00:00
christos 0d5e2b23a1 - dedup code
- add a safe_strftime() to handle error cases
2021-04-06 13:35:52 +00:00
simonb b9d1a3315c 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 .
2021-04-06 05:13:24 +00:00
kamil 41a1344d4e Add a fallback definition of LSDEAD in ps(1)
The symbol is no longer available in headers.

Requested by <mrg>
2019-06-19 21:25:50 +00:00
kamil 561652851d 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.
2019-06-18 02:23:29 +00:00
maxv a51b00c421 Don't display l_wchan, either there is something in l_wmesg and we display
it, or there's nothing and we print "-".
2018-09-19 15:20:39 +00:00
christos b02b35c97e use EXIT_FAILURE instead of 1 2018-04-11 18:52:05 +00:00
kamil b42c7b02bc 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>
2017-12-09 14:56:54 +00:00
christos 6721aabc1e Handle functions that use the offset from either kinfo_proc2/kinfo_lwp properly. 2016-12-12 20:35:36 +00:00
christos 5a6cfab10a provide a tree like display with -d, from FreeBSD 2016-12-02 21:59:03 +00:00
rin cc1877ba3a 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
2016-11-28 08:21:10 +00:00
rin b095bb75a7 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
2016-11-28 08:19:23 +00:00
joerg 0bab8dfecf Use l_wmesg if the string is not empty. Don't bother checking l_name for
nullness.
2014-11-15 01:58:34 +00:00
dholland 4e3b1a0bd4 Use an enum type for PRINTMODE vs. WIDTHMODE. Compiler output diffs have
been checked.
2014-04-20 22:48:59 +00:00
mlelstv b3dffa81d5 Add an LTIME column that prints lwp cputime. 2014-01-15 08:07:53 +00:00
matt da4f7877a7 Use C89 function definitions 2012-03-20 18:42:28 +00:00
wiz 6b6a89aacb Remove unused variable.
From cppcheck via Henning Petersen in PR 46002.
2012-02-13 12:55:28 +00:00
dholland e9b3916bd6 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.
2011-06-13 03:42:15 +00:00
christos da9c1e1b4d fix previous. 2011-01-22 21:09:51 +00:00
christos 055b26bb55 Make printing of lwp flags similar to the process one, identifying (O)nproc
(K)ernel threads and scheduler (a)ctivations.
2011-01-22 20:55:58 +00:00
njoly c45af2045a Do not check pcpu value against 100.0 but rather 99.95, to properly
deal with value rounding. From apb@.
2010-07-28 17:39:54 +00:00
njoly 0697f9d213 Make %cpu drop the decimal part when reaching 100%, to stay in the 5
expected columns.
2010-07-27 12:40:48 +00:00
rmind 8b95f823bf 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.
2010-05-31 03:18:33 +00:00
rmind 40cf6f3659 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>.
2009-10-21 21:11:57 +00:00
mrg fcc023545e - 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 :-)
2009-03-29 01:02:48 +00:00
lukem 990d25a96c fix -Wsign-compare issues 2009-02-14 08:02:04 +00:00
drochner cbbbda3b17 make sure the table stays aligned even if no groups are to be displayed
with the "groupnames" option
2009-02-03 17:37:02 +00:00
drochner 8b7f84e12c make sure the table stays aligned even if no groups are to be displayed
with the "groups" option
2009-02-03 17:33:42 +00:00
christos a5c6617db7 fix dev_t 64 bit issues. 2008-12-28 19:50:22 +00:00
christos cca36888f5 Use 'O' for LSONPROC like solaris instead of bundling LSIDL, LSRUN, LSONPROC
to 'R'
2008-10-19 02:39:08 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
christos da86f0e587 Add a CPUID keyword; idea and some of the code from Anon Ymous 2008-02-10 17:47:59 +00:00
ad 2ecdf58c2c Remove systrace. Ok core@. 2007-12-31 15:31:24 +00:00
ad bb6c89afbf Kill another use of PZERO. 2007-11-06 00:44:46 +00:00
yamt 37ac06be56 add a keyword "lname", to print l_name. 2007-09-01 16:54:39 +00:00
dsl bd8009e530 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
2007-07-28 17:05:50 +00:00
pavel f5e7ca2447 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.
2007-02-17 22:49:56 +00:00
ad 8966ad6a93 Further changes to use compat process flags mapped by sysctl. To be
revisited soon.
2007-02-10 18:20:12 +00:00
ad 401499f30e Sync with kernel changes introduced by merging the newlock2 branch. 2007-02-09 22:08:48 +00:00
christos d0a868f481 Add support for printing the emulation of the process. 2006-10-29 22:32:53 +00:00
apb d9463bc15b * 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.
2006-10-02 17:54:35 +00:00
christos 10a02919cc Add some more const so that this compiles again. 2005-06-27 00:46:04 +00:00
christos 6310b59691 sprinkle a little const, and now everything compiles with WARNS=3 2005-06-26 19:10:48 +00:00
he 1d55d88929 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.
2005-06-07 08:53:13 +00:00
christos 3e870b856b print TTY instead of TT, one question mark instead of two and always the
full tty name.
2004-11-16 04:58:14 +00:00
simonb 9bc855a931 s/the the/the/ (only in sources that aren't regularly imported from
elsewhere).
2004-04-23 02:58:27 +00:00
simonb d8f2ef9ae4 Gah, fix uninitialised variable with the "etime" change. _Never_ be
happy with something and then edit a single line before committing
without retesting...
2004-03-27 14:55:24 +00:00