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.
By default killall should not kill processes in a namespace it is not
part of. If this is allowed, it allows callers to break namespaces they
did not expect to affect, requiring rewrite of all callers to fix.
So by default, we should work in the current namespace. If -N 0 is
specified, then we look at all namespaces, and if any other pid is
specified we look in only that namespace.
Radu Rendec [Thu, 30 Jun 2016 16:15:21 +0000 (18:15 +0200)]
Avoid possible crash and memory leak in killall
In the case of a command line match, load_proc_cmdline would return a
pointer that was not obtained from malloc, which then would be freed in
kill_all. This behavior could result in a SIGSEGV.
In the case of an empty command line, load_proc_cmdline would return -1,
causing its internal buffer to be leaked in kill_all.
Signed-off-by: Radu Rendec <radu.rendec@mindbit.ro> Signed-off-by: Craig Small <csmall@enc.com.au>
Craig Small [Fri, 17 Jun 2016 22:00:10 +0000 (22:00 +0000)]
Merge branch 'hide_threads' into 'master'
Add option --hide-threads (-T) to hide threads from display
On desktop systems, there will usually be a gazillion of threads
(hello chrome!) that clutter the display. Add an option to optionally
hide these from showing up at all.
PS: Fwiw, I'd personally prefer to have threads hidden by default. If that's desired, I can update the patch to reverse the logic.
Christoph Berg [Sat, 21 May 2016 08:41:24 +0000 (10:41 +0200)]
Add option --hide-threads (-T) to hide threads from display
On desktop systems, there will usually be a gazillion of threads
(hello chrome!) that clutter the display. Add an option to optionally
hide these from showing up at all.
Craig Small [Sun, 1 May 2016 05:36:22 +0000 (05:36 +0000)]
Merge branch 'fix/pslog_unterminated_string' into 'master'
pslog: fix unterminated string and memory leaks
Adding null terminator to buf string.
Cleaned a memory leak calling closedir on /proc/$PID/fd, that was left open.
`==29483==
==29483== HEAP SUMMARY:
==29483== in use at exit: 0 bytes in 0 blocks
==29483== total heap usage: 256 allocs, 256 frees, 70,990 bytes allocated
==29483==
==29483== All heap blocks were freed -- no leaks are possible
==29483==
==29483== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==29483== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)`
Craig Small [Sat, 30 Apr 2016 23:14:40 +0000 (23:14 +0000)]
Merge branch 'master' into 'master'
Adding pslog(1): Report current log(s) path of a process
Simple binary to find the log(s) path for a given PID. Please review my code and highlight any mistake or anything missing. Thanks very much for your time.
Craig Small [Thu, 28 Apr 2016 12:16:51 +0000 (22:16 +1000)]
killall: fix malloc branch logic for pgid
A fix to remove some spurious code removed a branch and an else
but did not invert the if check like it should. It meant if
process groups were used the spaces was not allocated.
Craig Small [Mon, 25 Apr 2016 06:57:35 +0000 (16:57 +1000)]
fuser,prtstat: use standard sscanf flag for alloc
Previously GNU libc supported the a option in scanf, e.g.
%as to allocate the buffer for the scanned string. The manual
recommends to use m instead as it follows the standard.
Craig Small [Thu, 25 Jun 2015 11:31:17 +0000 (21:31 +1000)]
fuser: rework string comparison
This one is a patch that reworks the string comparision for file name
space in fuser. It makes the usage of this configurable with
--enable-mountinfo-list at build time as well as at runtime with
--inode. Also it uses shared memory maps to reduce the load on
write/read the stat buffers.
Craig Small [Sat, 14 Mar 2015 22:08:12 +0000 (09:08 +1100)]
fuser: -k return status based on any found
In [bugs:#66] the ever-helpful "Anonymous" reported that
fuser with -k would only return correctly if the process
was found last and not if it was found anywhere.
While I have solved this problem a different way, the report
was enough to narrow down what was going wrong. Now fuser -k
returns 1 if it finds any process to kill, not just if the last
one was; just like fuser with no -k works.
Werner Fink [Sat, 14 Mar 2015 21:39:12 +0000 (08:39 +1100)]
Avoid possible crash and memory leak in killall
By reading the current HEAD I stumbled on a memory leak in killall.c
as well as a not assigned pointer got_long in load_proc_cmdline()
which may lead to SIGSEGV.
References: [patches:#67] https://sourceforge.net/p/psmisc/bugs/67 Signed-off-by: Werner Fink <werner@suse.de>
Craig Small [Tue, 23 Dec 2014 21:35:34 +0000 (08:35 +1100)]
killall younger and older flags
The -y and -o flags were not being used if you used the
regex (-r) flag. I initially moved those flags to the
right part of the loop.
However looking at that giant loop of code it was very difficult
to debug so I have also taken the opportunity to re-work it
with some functions, so its clearer what is going on.
Craig Small [Mon, 22 Dec 2014 21:58:47 +0000 (08:58 +1100)]
Removed early free on name_len
name_len was being freed too early and in a loop so
sometimes you would hit a double-free problem
The locale changes were to keep efence happy though
i suspect something strange was going on with locales there
too.
Martin Schwenke [Tue, 25 Feb 2014 19:55:21 +0000 (06:55 +1100)]
pstree: Ignore processes that disappear before reading cmdline
The worst case here is that the user has specific a PID on the
command-line, read_proc() fails to read cmdline for an irrelevant,
transient process and fails.
It is better to simply ignore processes that have disappeared. That
way pstree can provide useful output in more cases.
An alternative is to read cmdline only for processes that the user is
interested in. However, this probably increases the chances of an
interesting process exiting before the cmdline is read.
Signed-off-by: Martin Schwenke <martin@meltin.net>