Craig Small [Mon, 2 Mar 2020 11:00:25 +0000 (22:00 +1100)]
pstree: minor snprintf fix
The referenced commit used size_t as a return value for
snprintf.
Coverity found the negative check against size_t but the real
problem was using size_t in the first place as an error
returned by snprintf would never be detected.
Craig Small [Mon, 2 Mar 2020 10:56:02 +0000 (21:56 +1100)]
killall: minor str length changes
reworked some of the string handling to check for strchr and
strrchr return values. Removed check for unsigned to be negative,
that's not going to happen!
Craig Small [Wed, 23 Oct 2019 10:34:51 +0000 (21:34 +1100)]
pstree: Add color by age
New -C and --color option sets the process color depending on its age.
Possibly one day a user could set the colors and ages but for now its
hard-coded.
pstree: make the long version of option -c describe what it does
Having a long option that says the opposite of what it actually does
is awkward. Choose to just extend its name to --compact-not, so that
scripts that use --compact will continue to work.
pstree: alphabetize the -g and -G options correctly in the usage message
And, as we're changing the usage string anyway, also slice it up into
overseeable chunks (for the translators), and always put the short and
the long option on the same line (as is done for -Z), so it is clearer
that they are the same option.
ARM64 copy user_pt_regs to user space instead of pt_regs.
So in this patch, mapping the require user_pt_regs except orig_x0,
as orig_x0 not available in user_pt_regs for SYSCALL exit.
For each SYSCALL, peekfd catches user_pt_regs for SYSCALL entry/exit.
Value of orig_x0 is available in user_pt_regs->x0 of SYSCALL entry.
So to get orig_x0, stores user_pt_regs of SYSCALL entry,
and then compare 'fd and addr of buffer' of SYSCALL exit
with SYSCALL entry to retrive orig_x0 at the time of SYSCALL exit.
This fixes out-of-tree builds which use
--disable-dependency-tracking. With dependency tracking enabled,
src/.deps is created as a side-effect of how dependency tracking
works, which is why this issue was never noticed before.
Craig Small [Wed, 7 Nov 2018 09:13:09 +0000 (20:13 +1100)]
killall: match on 16 character commlen too
The comm length increase meant killall could accomodate the
larger comm name given out by newer kernels but it meant that
if a user relied on the previous 16 character truncation then
processes that used to match would fail.
killall now checks to see if the the comm is the old COMM_LEN
length and the given name is longer than old COMM_LEN and does
a truncated match as well.
By explicitly specifying the dependency between signals.c and
signames.h.
BUILT_SOURCES only works with the standard targets, so if somebody tries
to build fuser directly he may end up with a build failure. What's
worse, he could do "make -j2 src/signames.h src/fuser" and he could end
up with a broken build using a only partially generated signames.h.
And that "somebody" was me when packaging killall in psmisc 22.21...
so it actually happens.
Craig Small [Sun, 20 May 2018 10:46:55 +0000 (20:46 +1000)]
killall: change to getopt_long
with getopt_long_only -ve fails because its not sure what the -v
is for --version or --verbose. Changing to the non-_only version means
it doesn't try to expand the options to long options.
Curently pstree does built, at least on ppc64le, because it does
not have a explicit link against gettext, causing the following error:
peekfd.o: In function `print_version':
peekfd.c:(.text+0x160): undefined reference to `libintl_gettext'
peekfd.c:(.text+0x18c): undefined reference to `libintl_gettext'
peekfd.c:(.text+0x1ac): undefined reference to `libintl_gettext'
peekfd depends on libint because of the following macro:
Craig Small [Sat, 5 May 2018 22:02:35 +0000 (08:02 +1000)]
killall: use all namespaces by default
This is similar to the revert in procps where namespace filtering
is added but by default it uses all of them. The issue is most people
expect to see/kill all processes and the namespace filtering causes
confusion, especially around ssh related processes.
Svante Signell [Mon, 12 Jun 2017 00:25:57 +0000 (10:25 +1000)]
pstree: Remove need for PATH_MAX
This commit removes the need for PATH_MAX in pstree.
It uses the fact that calling snprintf() with *str=NULL and size=0
returns the number of bytes needed for the string according to
POSIX.1-2001 and later (which is supported by all glibc versions
since 2.1, see snprintf(3)).
John Ferlito [Sat, 1 Apr 2017 23:20:33 +0000 (09:20 +1000)]
killall - Fix race condition for --older-than and --younger-than
If killall runs really quickly then it' possible for process_age to be
0.0. The existing logic will then always kill the process due t
"&& process_age" always being false in that case.
Jeff Smith [Thu, 16 Mar 2017 16:18:07 +0000 (11:18 -0500)]
killall: fix reporting when >32 names specified
Recording which named processes were killed is stored in an unsigned
long bitmask. Some of the bit-wise math is done with an int. If
sizeof(long) > sizeof(int), some not-found processes may not be reported
as such, and/or the return code may be wrong.
This is fixed by making sure bit-wise math is being done with a long.