Commit Graph

10 Commits

Author SHA1 Message Date
Jim Warner
08d0f377a7 top: eliminate that 'TOG4_NOTRUNC' compile conditional
When 2 abreast cpu display was introduced, the minimum
screen width was 160 columns so as to avoid (minimize)
truncation. Later that was reduced to 80 columns while
keeping the original minimum as a compile conditional.

In preparation for (virtually) eliminating these width
restrictions in a future patch this #define's history.

Reference(s):
. May, 2020 - introduced #define TOG4_NOTRUNC
commit be3dcaa842
. May, 2020 - introduce 2 abreast display
commit 59f5a37a24

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-09-12 22:15:28 +10:00
Jim Warner
d9c45988f7 top: eliminate that 'TOG4_NOFORCE' compile conditional
When two abreast display was introduce, in that commit
shown below, this #define provision was also added. It
actually was an artifact left from program development
and never made much sense in a real world application.

If activated it would make the '4' toggle appear to be
broken since it would only take affect if a user first
activated individual cpu display (the '1' toggle off).
And there was no error message offered to those users.

So, this questionable #define is now being eliminated.

Reference(s):
. May, 2020 - introduce 2 abreast display
commit 59f5a37a24

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-09-12 22:15:28 +10:00
Jim Warner
9d9993708b top: fix an improper behavior following a SIGWINCH bug
When top was made more responsive to keyboard input in
that commit referenced below, his previous response to
a SIGWINCH was upset. Formerly, that display integrity
was restored with the next refresh cycle. But, without
this patch, one must strike some key to accomplish it.

[ in truth, this patch vastly improves that sigwinch ]
[ response. whereas before, although integrity would ]
[ be restored automatically, it did not happen until ]
[ the next regular refresh. now it is instantaneous! ]

Reference(s):
. May, 2022 - made more responsive to kdb input
commit 3ea1bc779f

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-09-12 22:15:28 +10:00
Rafael Kitover
20c328bdcc Improve trace().
Turn on trace() with the TRACE macro and remove the ## token paste
preprocessor operator which is unnecessary here and causes these errors:

ps/common.h:176:26: error: pasting "(" and ""ps_argv[thisarg] is %s\n""
does no t give a valid preprocessing token
.

Send trace output to STDERR.

Tracing can be enabled by adding TRACE to CPPFLAGS as follows:

./configure CPPFLAGS="-DTRACE"

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-09-01 22:44:05 +00:00
Chris Down
2ba7e39f2b pgrep: Look at all ancestors in --ignore-ancestors
Previously we mistakenly only checked one previous level of the
hierarchy.

Signed-off-by: Chris Down <chris@chrisdown.name>
2022-08-31 10:25:49 +01:00
Chris Down
4b44ab98c1 pgrep: Add support for ignoring ancestors with -A/--ignore-ancestors
pgrep and friends naturally filter their own processes from their
matches. The same issue can occur when elevating with tools like sudo or
doas, where the elevating shim layers linger as a parent and are
returned in the results. For example:

    % sudo pkill -9 -cf someelevatedcmdline
    1
    zsh: killed     sudo pkill -9 -cf someelevatedcmdline

This is a situation we've actually seen in production, where some poor
soul changes how permission management works (for example with Linux's
hidepid option), needs to elevate a pgrep or pkill call, and now ends up
with more than they bargained for. Even after the issue is noticed,
resolving it requires reinventing some of the pgrep logic, which is
unfortunate.

This commit adds the -A/--ignore-ancestors option which excludes pgrep's
ancestors from the results:

    % sudo ./pkill -9 -Acf someelevatedcmdline
    0

We looks at multiple layers of the process hierarchy because, while
things like sudo only have one layer of shimming, some mechanisms (like
those found in a typical container manager like those found in Docker or
Kubernetes) may have many more.

Signed-off-by: Chris Down <chris@chrisdown.name>
2022-08-31 07:37:10 +00:00
Craig Small
f5ba25afe6 skill: Update include location too
skill got missed in the main update as its not compiled by
default.
2022-08-29 21:37:40 +10:00
Craig Small
47a8676625 build-sys: Relocate lib/
test files in lib go to src/tests
include/ goes to local/
lib/*.c goes to local/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 20:28:03 +10:00
Craig Small
3d0871728b build-sys: Relocate library to library/
All the dependent programs needed to have their includes moved too

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 19:02:44 +10:00
Craig Small
dd60d6d6e8 misc: Move all binaries to src
*.c -> src/
ps/* src/ps/
top/* src/top/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 18:29:28 +10:00