Commit Graph

33 Commits

Author SHA1 Message Date
Jesse
c06458e1c1 Accepted patch from Mark Hindley which avoids clearing realpath information
in pidof when trying to find matching executables.
2023-04-18 17:33:30 -03:00
Jesse
b6aacf3b68 Fixed memory initialization error in pidof. Fix provided by Markus Fischer. 2023-03-24 11:18:02 -03:00
Jesse
b70b2776ed pidof was not returning PIDs of programs which were launched
using a symbolic link. (ie /tmp/sleep when /tmp/sleep links to /usr/bin/sleep).
This is now fixed as we check both the realpath and symbolic path for processes.
In other words, "pidof /tmp/sleep" and "pidof /usr/bin/sleep" will return
the same PIDs when /tmp/sleep is a symbolic link to /usr/bin/sleep.
2023-03-22 12:34:55 -03:00
Jesse
86c5d7b93c Fixed killall5 usage message to be more accurate. Command
can accept more than one parameter and that is now mentioned.
2023-02-19 00:47:22 -04:00
Jesse
bd55f5e243 The killall5 command now avoids sending any signals,
including SIGSTOP and SIGCONT, to processes on the omit list.
2023-02-19 00:42:55 -04:00
Jesse Smith
0b695c7e0b Use readlink() instead of stat() to check processes. This shold avoid
hanging if NFS mounts are not responding.

Default to showing processes in the uninterruptable state (D).
The -z flag no longer affects whether processes in D state are shown.

The -z flag does still toggle whether zombie (Z) processes are shown.
2021-10-21 14:44:55 -03:00
Jesse Smith
ab53132154 Removed old original source file that was left behind by
patch action.

Fixed typos in source code, comments, manual pages, and
changelog. Corrections provided by Jens Schleusener of
FOSSIES (fossies.org).
2020-11-17 20:31:37 -04:00
Jesse Smith
9bc925d0e9 Avoid freeing unused memory. Some code clean-up.
Patch provided by David Hoyer.
2019-11-04 12:12:44 -04:00
Jesse Smith
39df2f0fa3 Added -z command line paramter to pidof which tells pidof to
try to find processes in uninterruptable (D) or zombie (Z) states.
This can cause pidof to hang, but produces a more complete process
list.
2019-07-04 22:00:47 -03:00
Jesse Smith
df1aec8981 Accepted patch from Luc Gommans which explains why zombie and
deep sleep processes (Z and D) may be hidden from pidof
2019-05-25 15:41:57 -03:00
Jesse Smith
f1da344565 Dropped "-f" format flag for pidof command as it
could be used to print information from memory or crash
pidof. Replaced flag with "-d" which allows for a custom
separator to be used between listed PIDs.
Patch supplied by KatolaZ.
2019-03-20 13:46:36 -03:00
Jesse Smith
4e2ad6a698 Fixed segfault in pidof when the -f (format) flag is used with
crafted format strings.
Avoid printing stack memory when special format string is passed
to -f.
Listed control characters for -f flag in manual page.
2019-03-18 18:09:24 -03:00
Jesse Smith
483dc777d2 Changed the way the "when" variable is used internally in shutdown.c.
It starts as a NULL pointer, then might get set as a pointer to optarg,
then it might get set to point to an argv parameter, then it might have
a string value copied into it, over-writing the original data. We should
not risk over-writing internal variables which might get used for something
else (it's rude and security risk). Set up "when" as its own buffer
that has data from optargs and/or argv copied into it.

Minor code fixes across multiple source files to avoid buffer
overflows, or uninitialized strings.
2019-01-27 15:55:08 -04:00
Jesse Smith
9e8553cacb Updated copyright in init and removed unused Version variable from killall5.c 2018-12-27 15:31:14 -04:00
Jesse Smith
c03e2fac2b Added fix to pidof which re-enabled the omit (-o) flag.
this was broken when formatting was added in the 2.92 release.
Closes Debian bug #914494.
2018-11-23 18:00:23 -04:00
Jesse Smith
aa6873b85b Removed typos from pidof manual page and killall5 page.
Closes Debian bugs #815839, #905245 and #890478

Added -f <format> option to pidof program to allow printf
style formating.
Closes Debian bug #571590
Thanks to Philipp Marek for the patch.
2018-11-10 21:27:11 -04:00
Jesse Smith
1b659c8ebe Applied patch from Daniel Povey which should allow killall5/pidof to
avoid locking up if it encounters stopped or zombie processes
due to broken NFS mount points.
This should allow Debian bug #719273 to be closed.
2018-10-27 20:26:15 -03:00
Jesse Smith
f1ca96e1c1 Added patch from Walter Harms which allows pidof to run without
displaying output. In this mode pidof simply returns true or false
without displaying PID values.

Updated manual page with new -q (quiet) mode.

Added -h flag for pidof, which was recognized before, but not used.
The -h flag now displays brief usage information for pidof.
2018-09-08 17:19:21 -03:00
Jesse Smith
e0cfd39728 Added "Fall through" comments to some switch statements where multiple
approaches are tried in order to prevent warnings from GCC 7 (and newer).

Added includes on Linux for sys/sysmacros.h as the old defines in
the sys/types.h file will be removed in the future.
2018-05-04 14:51:40 -03:00
Jesse Smith
6a8a216449 Fix typo in killall5.c and move initscript.sample file
from source tree into "doc" directory.
2018-02-20 19:36:21 -04:00
Petter Reinholdtsen
b8e970ca10 Explain why maxsymlinks() exist. 2014-02-05 13:23:08 +00:00
Petter Reinholdtsen
834bcebcaf Use sysconf(_SC_SYMLOOP_MAX) instead of MAXSYMLINKS. If sysconf
returns an error, fall back to MAXSYMLINKS on platforms that
define it.  Fixes build on Hurd.  Patch from Justus Winter and
Debian.
2014-01-28 10:13:10 +00:00
Werner Fink
1017641f3e Shutdown: use PATH_DEFAULT as suggested by Paul Arthur in local bug #36101
Killall5/pidof: handle strange names of executables (local bug #36252)
Sulogin: be aware the crypt(3) may fail (local bug #36313)
2012-10-11 13:10:40 +00:00
Werner Fink
99a0a2583f * Handle deleted binaries in pidof (was local bug #34992) 2012-03-16 16:46:06 +00:00
Werner Fink
6fe3edd48c Add some code to be able to detect programs even as user with
kernel 3.0 and above
2011-10-17 12:53:27 +00:00
Werner Fink
d9122565a0 * Fix counting message lines in wall. Patch from Petr Lautrbach.
* Fix bad printf conversion specifier in wall. Patch from Sébastien Luttringer.
* Add patches from Openwall project. Thanks goes to Solar Designer.
2011-03-15 13:16:55 +00:00
Werner Fink
e1a1f90204 Correct position of string pointer in NFS struct used in killall5/pidof 2010-10-21 09:47:16 +00:00
Werner Fink
27821f3c1b * Include limits.h in killall.c to enforce definition of PATH_MAX 2010-04-28 08:31:17 +00:00
Werner Fink
2950c304a1 * Increase buffer size for path checking to normal limit PATH_MAX+1 2010-03-19 14:10:55 +00:00
Werner Fink
94a203f9e1 remove empty blanks from empty lines 2010-03-19 14:09:15 +00:00
Werner Fink
1107f3ba7d * pidof - shorten list check a bit for network based processes 2010-02-23 17:12:12 +00:00
Werner Fink
9e449b3f6d * pidof/killall5 - make omit pid list a dynamic one.
* pidof - provide '-n' to skip stat(2) syscall on network based FS.
2010-02-23 16:51:18 +00:00
Petter Reinholdtsen
2fe47a3c9f Drop hurd specific dependency on libc0.3 (>= 2.3.2.ds1-12). It is
no longer needed according to Michael Bunk.  Patch from Michael
Biebl.
2009-09-10 08:28:49 +00:00