Commit Graph

323 Commits

Author SHA1 Message Date
Craig Small
06e3cd6e51 NEWS: Set version to 4.0.1 2022-10-20 20:58:25 +11:00
Craig Small
8f1b7070b7 NEWS: Add entry for free --si fix
References:
 procps-ng/procps!163
2022-09-28 17:59:23 +10:00
Jim Warner
4b607edc12 doc: updated with library p-core/e-core identification
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-09-28 17:30:56 +10:00
Jim Warner
fd529e9679 doc: top now has more than two abreast summary display
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-09-12 22:15:28 +10:00
Craig Small
8eee6cc48c misc: Update NEWS/man date for pgrep -A
Added NEWS item
Update pgrep.1 date

References:
 commit 4b44ab98c1
2022-08-31 17:43:17 +10:00
Craig Small
1502648ff9 library: Rename to libproc2
The newlib library used to be called libproc-2 but the new
name is preferred.

References:
 https://www.freelists.org/post/procps/Next-for-newlib,3

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 20:38:17 +10:00
Craig Small
95a253aa6e pgrep: Better warning if pidfd_open not implemented
If procps is built on a Linux 5.3+ system then pidwait
is built with pidfd_open(). If that program is run on
a system < 5.3 then it gives an odd generic error.

If we get a ENOSYS from one pid, we will get it for all
the others so its better to explain what happens and terminate.

The man page is updated to note this issue.

This came up due to killall in psmisc using pidfd_send_signal

References:
 https://bugs.debian.org/1015228

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-07-18 20:51:41 +10:00
Craig Small
8ca346762d doc: Note new Used behavour
Added note to NEWS in the lbirary section
Updated free.1 as it specifies the calculation

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-06-25 11:42:08 +10:00
Jim Warner
2282c74c33 NEWS: acknowledge that utf8 multi-byte character input
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-14 21:52:14 +10:00
Jim Warner
60bac2b544 doc: acknowledge the top 'message log' display ability
[ along the way, we'll fix-up the section 4 commands ]
[ summary which has gotten a little outdated lately. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-05 21:11:38 +10:00
Craig Small
3ee7a4d7f9 docs: Update news for watch equexit
References:
 commit 3ac20bf536
2022-05-18 21:50:14 +10:00
Jim Warner
381af1af81 doc: detail 'Ctrl' bottom window namespaces plus focus
[ along the way we will restore '^R' to keys summary ]
[ plus correct a leftover reference to 'Ctrl-V' too. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-16 20:05:59 +10:00
Jim Warner
6b24d11b07 doc: add variable width data display without scrolling
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-03 19:21:21 +10:00
Craig Small
1f085f5a9f pmap: Don't reopen stdin for reading file
pmap uses freopen to read /proc/self/maps. There doesn't
seem to be a good reason to do this and if pmap has its
stdin previously closed then it fails.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-04-26 21:18:03 +10:00
Jim Warner
df4d2dc570 doc: added provision for autogroup nice (AGNI) changes
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-04-26 20:18:15 +10:00
Jim Warner
ef8d1cb6e3 top: remove those winflags which restricted 'x' toggle
On occasion, even as the top author, I wonder why that
'x' toggle has stopped working. Of course, it actually
was working but a locate request ('L') or other filter
('O') operation was active and thus temporarily turned
if off. Such behavior is documented in top's man page.

Well, with this patch that 'x' suppression is no more.

[ the original justification, however, remains true. ]

[ but there's really only one character which causes ]
[ any potential trouble & i'm gonna' keep it secret. ]

[ besides, if a display is corrupted, there's always ]
[ that '=' key which restores things back to normal. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-04-17 10:43:19 +10:00
Jim Warner
9e77e138c1 library: fix 'smaps' bug preventing a build with clang
As a result of the issue referenced below, we'll trade
our homegrown offset generator for an 'offsetof' macro
found in the stddef.h header file. This pleases clang.

[ and thanks to Daniel Kolesa for the report and fix ]

Reference(s):
. bug report & recommended solution
https://gitlab.com/procps-ng/procps/-/issues/235

. clang error message
proc/readproc.c:673:9: error: initializer element is not a compile-time constant
        mkENT(Rss),
        ^~~~~~~~~~
proc/readproc.c:661:34: note: expanded from macro 'mkENT'
  #define mkENT(F) { #F ":", -1, (int)((void*)&q->smap_ ## F - (void*)&q->fZERO) }
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-04-11 16:41:12 +10:00
Craig Small
b159c198c9 sysctl: print dotted keys again
When the globbing update was put into sysctl, you could no longer
simply use the keys because one key could potentially be
multiple paths once the glob expansion occured.  Using the path
instead gave a unique output.

Except certain programs, such as salt, expected the output to use
the dotted path "kernel.hostname" and not "kernel/hostname".

We can no longer use the original key, so now for each path:
  Copy the path
  strip off /proc/
  convert all / to .

The sysctl testsuite was also updated to check for a few different
types of conversion failures.

References:
 commit 6389deca5b
 https://www.freelists.org/post/procps/some-procpsn4400-fixes,4
 https://repo.saltproject.io/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-04-09 14:18:28 +10:00
Jim Warner
197728491a NEWS: update with 2 ps related release 4.0.0 bug fixes
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-04-09 12:56:36 +10:00
Craig Small
4f55ee227d NEWS: Mention elogind merge
Reference:
 procps-ng/procps!151
2022-04-01 17:28:53 +11:00
Craig Small
ed5fe5f8b3 misc: Add v4.0.0 to NEWS 2022-03-23 17:56:11 +11:00
Jim Warner
5c4c239257 doc: document 'scale_tics' function for Ctrl-E scaling
[ i also tweaked that 'STARTED' narrative just a bit ]
[ since its original wording implied the value could ]
[ change, whereas it's fixed when a task is started. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-06 14:52:34 +11:00
Jim Warner
a39f2bffdc doc: updated with new 'start time' & 'cpu utilization'
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-02-27 21:27:02 +11:00
Craig Small
e5542f1fc3 free: Use wstr width and not length
The previous commit used the value from mbstowcs() to work out
the spacing required, as printf() got it completely wrong.

However, for alignment of text you don't use the string length
but the string width.

As the referenced website says:
 Use wcslen when allocating memory for wide characters, and use wcswidth to
 align text.

Which is what free does now. Chinese is still off by one but I cannot
see why this is so. It's close enough for now. If someone can work
it out, I'd love to know what the fix is.

As a side effect, #213 is fixed because we are putting the correct
number of spaces in.

French is still an issue (see #24 ) but this is because the string is
too long!

References:
 procps-ng/procps#24
 procps-ng/procps#213
 procps-ng/procps#229
 commit 9f4db0fb56
 https://www.linux.com/news/programming-wide-characters/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-02-01 16:46:09 +11:00
Craig Small
9f4db0fb56 free: Fix first column justification
free has for many years had a problem with translated header columns
or the first column. This is because printf("-9s", str) doesn't use
the wide length of the string but the char length meaning they are
mis-aligned.

Using the mbstowcs() function to get the wide length and then
a precision parameter to append the right number of spaces after the
number means we get what we need.

References:
 procps-ng/procps#229
 procps-ng/procps#204
 procps-ng/procps#206
 https://bugs.debian.org/1001689

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-01-31 18:14:12 +11:00
Jim Warner
50a0d9a56c NEWS: updated to acknowledge 'LIBPROC_HIDE_KERNEL' var
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-31 18:10:48 +11:00
Craig Small
4cfb0fb763 pgrep: Match on cgroup v2 paths
You can match or filter on cgroup paths. Currently the match is only
done for version 2 cgroups because these are way simpler as they have
a unified name and always start with "0::".

cgroup v1 can have:
 named groups "1:name=myspecialname:"
 controllers "9:blkio:"
 multiple controllers! "4:cpu,cpuacct:"

So they are very much more complicated from a options parsing and
cgroup matching point of view.

In addition, both my Debian bookworm and bullseye systems use
v2 cgroups.

$ ./pgrep --cgroup /system.slice/cron.service
760

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2021-10-26 20:56:19 +11:00
Craig Small
14d6ab27d6 NEWS: Add entry for free -h --si fix
References:
 commit 91e5879228
 Issues #133 #223
 merge !140
2021-10-26 18:25:37 +11:00
Todd Lewis
e500ba6d97 fix uid/gid > 2^31
This MR revisits a partial fix from 2018. The problem stems from incorrect
handling of unsigned 32-bit uid_ts and gid_ts as signed when values are
large - i.e. when the high bit is set. In that case, pgrep and pkill fail to
identify processes by uid. (They succeed when finding the same processes by
username.) The primary fix for this is to impliment the "FIXME" comment in
proc/readproc.h, the implementation of which allows the removal of the (int)
casts from the partial fix from 2018.

The other fixed code in this MR consists of tests in strict_atol() that
detects and errors out on overflows.

References:
 Merge !146
2021-10-26 18:13:48 +11:00
ed neville
0496b39876 uptime: Correctly print pretty/short format
uptime -p would show empty output after 52 weeks of uptime. This commit
is largely the work of Ed but reformatted for newlib branch.

Signed-off-by: Craig Small <csmall@dropbear.xyz>

References:
 procps-ng/procps!141
 procps-ng/procps#217
2021-10-14 19:37:42 +11:00
Craig Small
5f760d5085 vmstat: Add NEWS and man page for previous 2021-10-14 18:52:34 +11:00
Craig Small
db861f2ce6 misc: Add NEWS for ps ignoring SIGURG
References:
 commit b6ccf865f8
2021-10-14 07:52:43 +11:00
Craig Small
75ba637182 docs: Add note in sysctl.conf.5 for line length
References:
 procps-ng/procps#77
2021-09-15 21:45:26 +10:00
Jan Rybar
08aa15ce4b sysctl: Return non-zero if param setting failed
Real usecase:
'sysctl -w user.max_uts_namespaces=2147483648; echo $?'
returns 0 even though it failed with EINVAL

The close_stream() realised there was an issue and printed an
error but didn't change the return value.

Slightly modified merge request.

References:
 procps-ng/procps!76

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2021-09-15 21:07:43 +10:00
Craig Small
e886010ef7 misc: Add NEWS for previous
References:
 procps-ng/procps!91
2021-09-15 20:54:30 +10:00
Craig Small
6389deca5b sysctl: Support systemd glob patterns
systemd-sysctl handles glob patterns along with overrides and
exceptions. Now the procps sysctl does it too.

The return value for sysctl is consistently either 0 or 1.

Added tests to check sysctl functions.

References:
 procps-ng/procps#191

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2021-09-15 20:07:32 +10:00
Jim Warner
2d75b2eb96 NEWS: update to acknowledge top's long cmdline options
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-09-07 08:02:43 +10:00
Jim Warner
949382afe5 NEWS: announce changes for displaying autogroup values
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-09 22:00:23 +10:00
Jim Warner
6318010dab top: document summary area changes involving 2 abreast
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-06 20:17:51 +10:00
Jim Warner
37a4601882 top: introduced new focus toggle ('F'), man doc & NEWS
[ i also corrected an unrelated typographical error! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-07-27 21:17:18 +10:00
Jim Warner
963d8ad52f NEWS: just play catch up with some top implementations
These changes were already implemented for this newlib
version, but not in the the master branch top version.

[ and we also add the missing 3.3.17 ps 'exe' change ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-07-27 21:17:18 +10:00
Craig Small
f25d462166 sysctl: Check path is under /proc/sys
sysctl would try to read/write any path you gave it either on
the command line or configuration file. It would append /proc/sys
on the path but not check for any sneaky path traversal with ../

This commit means it first resolves all paths using realpath(3)
and then checks the path starts with "/proc/sys/"

At first I thought this might be a non-issue, but perhaps someone
could put a file into the sysctl configuration path and.. do
something? Anyway its a 8-line fix and makes things more correct.

References:
 #179

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2021-07-20 22:36:15 +10:00
Jim Warner
05a720fdba doc: updated NEWS plus top(1) for IO accounting fields
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-06-25 15:25:51 +10:00
Craig Small
e782b1d859 ps: Add PSS and USS fields
The library added smaps_rollup fields in the referenced commit.
This commit exploits the new fields to give pss and uss options.

These options were first proposed back in 2015 by Petr Malat
and, with the library update, they are finally made it into ps.

Why use proportional or unique segment size? It is argued that
these give a better idea of the "real" memory usage of a process.

References:
 commit 12543b6c76
 issue #112
 https://www.freelists.org/post/procps/PSS-and-USS-support-for-ps
 https://lwn.net/Articles/230975/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2021-06-16 21:13:52 +10:00
Craig Small
16734d580e free: option to show memory commit limits
This commit is largely the userland only changes found in !73
added by Jens Låås (@jelaas)

References:
 procps-ng/procps!73
2021-06-16 20:29:03 +10:00
Jim Warner
9bdc1ca295 NEWS: add comments for the new smaps_rollup provisions
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-04-29 21:42:45 +10:00
Craig Small
feb7b5aa45 misc: Add NEWS item for previous 2021-04-24 23:17:35 +10:00
Craig Small
992b8b64f4 pkill: Add lt- variants
The pgrep code checks to see if the program is run as pkill or pidwait
and changes its behaviour accordingly.  Some older versions of libtool
run the programs as lt-pkill and lt-pidwait which means the tests fail.

We add these two program names to the checks.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2021-04-05 14:40:00 +10:00
Craig Small
2e1e8fcc85 slabtop: Check for bad d and o option combination
If you run slabtop with the -d option and then -o option the
delay gets set to zero and it runs forever. slabtop now checks
for this combination and errors.

Adding a DEJAGNU test also found that none of the slabtop
checks were running so they got added to the list and only the
ones that need /proc/slabinfo (if not readable) are skipped.

References:
 #160
2021-03-11 22:10:37 +11:00
Craig Small
9ddbc82000 ps: Add OOM and OOMADJ fields
top has had the OOMs and OOMa fields since 2011. Ten years its
probably time that ps had these fields added too.

ps output options have oom and oomadj for OOM Score and OOM Adjustment
respectively.

References:
 procps-ng/procps#198
 commit 367fd902da
 https://www.freelists.org/post/procps/PATCH-12-Add-missed-oom-support-to-libproc
2021-03-05 17:22:29 +11:00