Commit Graph

336 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
msaitoh 763440c947 s/maxiumum/maximum/ 2021-11-06 06:38:03 +00:00
christos a83514c691 Don't assign v to newvar, so we can still access the original length. 2021-09-15 13:16:57 +00:00
christos bd3ed7c8b3 reflect reality on flags. 2021-09-14 22:14:11 +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
rillig 4cb8752908 bin: remove unnecessary lint comment CONSTCOND
Since 2021-01-31, lint no longer warns about 'do ... while (0)'.

No functional change.
2021-09-10 22:11:03 +00:00
christos 7c3f3593b8 use parsenum like everywhere else in the code. 2021-06-04 22:39:41 +00:00
wiz de71cbe121 Sort options in usage. 2021-06-04 08:17:53 +00:00
wiz af80e63ad4 Sort options in synopsis. 2021-06-04 08:16:14 +00:00
cjep e31566ddc3 PR standards/11223
Add -G to take a single group argument heading towards POSIX.2 compliance.
Patch from jperkin and reviewed by simonb.
2021-06-04 06:28:42 +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
simonb 13a10d0d01 We only need -Wno-format-y2k for print.c . 2021-04-06 04:49:41 +00:00
simonb e960fc946b Don't rely on the USPACE kernel define as a fallback if the vm.uspace
sysctl fails.  We've got bigger problems if the sysctl fail anyway.
2020-08-26 10:54:12 +00:00
kamil 5626006fd5 ps(1): Guard freeing the memory of pinfo with __NO_LEAKS.
No more leaks are detected by LSan/NetBSD as of the LLVM snapshot
(clang10svn) from 2019-09-15.
2019-09-15 15:27:50 +00:00
kamil fd0c6ecff6 Plug memory leak in ps(1)
pinfo is allocated in setpinfo() with calloc(3).

Free it when no longer used, just before the program termination.

Detected with LSan.
2019-09-11 17:02:53 +00:00
kamil 37157e31f8 Restore maxrss, idrss, isrss, ixrss printing in ps(1)
The RSS related statistics are now back in the NetBSD kernel.

These values were disabled since day0 until today.

libkvm(3) users will still receive inappropriate values as RSS statistics
are updated upon sysctl(3) call.

Patch submitted by <Krzysztof Lasocki>
2019-08-06 18:07:51 +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 ea7b28924d kvm_geterr() already contains errno, use errx. 2018-04-11 18:52:29 +00:00
christos b02b35c97e use EXIT_FAILURE instead of 1 2018-04-11 18:52:05 +00:00
kamil 0e68b604ab Fix an unitialized memory read bug in ps(1)
rawcpu of type int, is declared inside main(){} and it can be passed as
uninitialized to setpinfo().
The setpinfo() function has a switch checking the value of rawcpu:

  if (!rawcpu)
    pi[i].pcpu /= 1.0 - exp(ki[i].p_swtime * log_ccpu);

rawcpu is set to 1 with the command line argument "-C".

   -C           Change the way the CPU percentage is calculated by using a
                "raw" CPU calculation that ignores "resident" time (this
                normally has no effect).

Bug reproducible with an invocation: "ps u". It hides with "ps uC".

Initialize rawcpu by default to 0, before the getopt(3) machinery.

Detected with MSan running on NetBSD/amd64.

Sponsored by <The NetBSD Foundation>
2018-01-12 23:01:14 +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
wiz 21f891a499 Bump date for previous. Remove/replace bogus Tn uses. 2017-08-28 05:57:37 +00:00
kamil a69b333e73 Remove the filesystem tracing feature
This is a legacy interface from 4.4BSD, and it was
introduced to overcome shortcomings of ptrace(2) at that time, which are
no longer relevant (performance). Today /proc/#/ctl offers a narrow
subset of ptrace(2) commands and is not applicable for modern
applications use beyond simplistic tracing scenarios.

This removal will simplify kernel internals. Users will still be able to
use all the other /proc files.

This change won't affect other procfs files neither Linux compat
features within mount_procfs(8). /proc/#/ctl isn't available on Linux.

Remove:
 - /proc/#/ctl from mount_procfs(8)
 - P_FSTRACE note from the documentation of ps(1)
 - /proc/#/ctl and filesystem tracing documentation from mount_procfs(8)
 - KAUTH_REQ_PROCESS_PROCFS_CTL documentation from kauth(9)
 - source code file miscfs/procfs/procfs_ctl.c
 - PFSctl and procfs_doctl() from sys/miscfs/procfs/procfs.h
 - KAUTH_REQ_PROCESS_PROCFS_CTL from sys/sys/kauth.h
 - PSL_FSTRACE (0x00010000) from sys/sys/proc.h
 - P_FSTRACE (0x00010000) from sys/sys/sysctl.h

Reduce code complexity after removal of this functionality.

Update TODO.ptrace accordingly: remove two entries about /proc tracing.

Do not keep legacy notes as comments in the headers about removed
PSL_FSTRACE / P_FSTRACE, as this interface had little number of users
(close or equal to zero).

Proposed on tech-kern@.

All filesystem tracing utility users are encouraged to switch to ptrace(2).

Sponsored by <The NetBSD Foundation>
2017-08-28 00:46:06 +00:00
wiz 01869ca4d2 Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
rin f637bb05bd simplify logic; there must be no CPU usage when p_swtime is zero 2016-12-26 20:52:39 +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
rin 078edf9ccc KNF
ok martin
2016-11-28 08:18:27 +00:00
sevan 51fe790c4c Drop main() prototype. 2016-09-05 01:00:07 +00:00
sevan 0b822dfa9c Earliest reference in the TUHS archive is v3
Unfortunately only the source code for the compiler is present for that
release. The v2 archive is missing the manuals & only contains a some of the
commands.
Switch to v3 and reference manual category eight, as per r1.32 of
src/bin/ps/ps.1 from OpenBSD.
Heads up from Ingo Schwarze.
2016-08-10 22:00:56 +00:00
sevan abc56c017d Document the version ps first appeared. 2016-08-10 18:44:50 +00:00
christos 7da746ab02 remove \n from error messages 2015-06-16 22:31:08 +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 f86ebf3938 Don't print junk errnos. Avoids:
% ps -tfoo
  ps: /dev/ttyfoo: Undefined error: 0
  Exit 1
2014-06-28 17:32:27 +00:00
dholland a468ec4988 Don't bother using variables whose value is never changed from the
initialization value.
2014-04-20 23:31:40 +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
dsl dc210c7fbd Remove some pointless inclusions os sys/user.h 2014-02-19 20:42:14 +00:00
wiz 2161b7b1e3 Bump date for previous. 2014-01-15 09:24:31 +00:00
mlelstv 067314c61e Make ps -s use LTIME instead of TIME in the default output format. 2014-01-15 08:09:10 +00:00
mlelstv b3dffa81d5 Add an LTIME column that prints lwp cputime. 2014-01-15 08:07:53 +00:00
joerg 1907ec3a61 Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.
2012-06-03 21:42:44 +00:00
joerg 763e57918f Push logic to convert a ttyname to a device number into its own
function. Improve dealing with ptyfs by explicitly handling missing
pts/%d entries, if the kernel supports the pts device (PR 40813).
2012-05-07 13:14:31 +00:00
wiz d1cbb54293 Increase width of table column so it formats more nicely. 2012-04-15 21:20:16 +00:00