Commit Graph

26 Commits

Author SHA1 Message Date
Craig Small
2fa3bb0669 misc: update for pgrep runstate
Added some minor fixes and notes
2019-03-05 07:59:48 +11:00
ed
e13eb8b75e pgrep.c: Match based on process run state for issue 109 2019-03-05 07:53:59 +11:00
Craig Small
dd47a9744f docs: Update pgrep.1 example to more modern browser 2017-12-22 14:56:08 +11:00
Craig Small
625d0809da pkill: Return 0 if successfully killed process
Original report:
When trying kill a process with insufficient privileges (see blow),
pkill displays the error message “... failed: Operation not permitted”,
but returns 0. Surely it should return 3?

$ pkill syslogd ; echo $?
pkill: killing pid 373 failed: Operation not permitted
0

Return value 0 means one of more things matched. For a pgrep (which
shares code with pkill) this makes sense, there was a match. It seems
wrong for pkill to return 0 when it in fact could not do what you told
it to.  However return value 3 means a fatal error and it's not fatal.

Looking at other programs when trying to kill things it cannot kill.
shell kill returns 1, procps kill returns 1, killall returns 1, skill
returns 0 (and says it was successful!, ah well poor old skill)

The consensus seems to be that you return 1 if you cannot kill it, even
if you found it. In other words the return value for both not found and
not able to kill it is the same.

pkill only returns 0 if something was killed. This means we found a
match AND the kill() system call worked too.

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

Signed-off-by: Craig Small <csmall@enc.com.au>
2017-02-04 11:44:01 +11:00
William Orr
9742c74e7c pgrep: Enable case-insensitive process matching
FreeBSD has case-insensitive matching of processes in pgrep and
pkill, which can be super-useful. This patch uncomments and
documents the code needed to make this work.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-05-10 17:42:09 +10:00
Craig Small
fd77ca1dc6 pgrep.1 removed STANDARDS section
pgrep got updated due to the confusion of the f,l and a flags.
While the newer behaviour is far better but it is no longer following
the ancient Solaris standards, so that got removed.

References: https://bugs.debian.org/752501
2015-03-17 22:43:22 +11:00
Aristeu Rozanski
de7b3b9222 pgrep: introduce support for namespaces
A PID should be specified with --ns:
	$ pgrep --ns 12345
which will only match the processes which belong to to the same 6
namespaces. It is also possible to specify which namespaces to test:
	$ pgrep --ns 12345 --nslist mnt,net,ipc
which will match processes that belong to the same mount, network and
IPC namespaces as PID 12345.

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
2013-04-16 15:05:31 -04:00
Roberto Polli
aa5a19620b support for listing thread ids (useful with iotop) 2013-03-18 11:58:47 +01:00
Jim Warner
fe75e26ab6 miscellaneous: clean up trailing whitespace throughout
The entire tree's polluted with inappropriate trailing
whitespace. This commit rids our environment of all of
those useless keystrokes. Unfortunately, it sure ain't
a permanent solution and requires every contributor to
instruct their editor(s) to prevent or eliminate them.

Plus it's strongly recommended we all insert something
like what's shown below to our '.gitconfig' file so as
to provide at least some warnings when we try to apply
any patches (git am) that do contain the #@!%& things!

References(s):
~/.gitconfig excerpt ---------------------------------
[core]
  whitespace = trailing-space, space-before-tab, blank-at-eof
[apply]
  whitespace = warn
--------------------------------- ~/.gitconfig excerpt

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-14 12:36:47 +01:00
static.vortex@gmx.com
cff3960c4a pgrep: Documentation fixes
Minor fixes to the help output and manpage of pgrep.
2013-02-18 21:41:31 +11:00
Craig Small
ce95dd53eb Add -c count option to pkill
Possibly by a side-effect but pkill -c option used to work which would
print the number of killed processes.  This small change restores this
functionality.

Bug-Debian: http://bugs.debian.org/693783

Signed-off-by: Craig Small <csmall@enc.com.au>
2012-11-21 22:11:17 +11:00
Craig Small
9a60202b81 pgrep delimeter to delimiter
pgrep used delimiter and delimeter, the correct spelling is delimiter.
Thanks to Alexander Kobel for the heads-up.

Signed-off-by: Craig Small <csmall@enc.com.au>
2012-10-11 21:34:50 +11:00
Alfredo Esteban
f12277c74d Debian Bug report #526355
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=526355

Flag -f doesn't modify output anymore.

There is a new flag -a to show full command line processes.

Signed-off-by: Alfredo Esteban <aedelatorre@gmail.com>
2012-08-29 16:47:51 +10:00
David Prvot
889f1bebc0 docs: pgrep.1 groff syntax fix
Long option '--list-name' is fixed to be bold, and '-n, --newest'
are marked to new paragraph.

Bug-Debian: http://bugs.debian.org/665425
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-05-07 09:01:10 +02:00
Sami Kerola
47100a8125 docs: fix manual page warnings
All warnings where about unnecessary quoting.  The scriptlet
below will tell what was wrong.

for I in ./top/top.1 ./ps/ps.1 ./*.[0-9]; do
    echo "== $I warnings =="
    man --warnings=all $I > /dev/null
done

This should probably be turned to 'make check' script.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-16 12:55:53 +02:00
Sami Kerola
96ba57b568 docs: inform about pkill and --inverse option
The short option for --inverse is disabled for pkill, but long option
works just in case someone will find that piece of functionality usable.

Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=558044#67
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-13 21:26:01 +01:00
Sami Kerola
1af18c260a pkill: remove -v match inversion option
The option -v does not make much sense in pkill context.

Reported-By: "Jason A. Spiro" <jasonspiro4@gmail.com>
Bug-Debian: http://bugs.debian.org/558044
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-11 21:43:13 +01:00
Sami Kerola
1cde286c75 docs: add to pgrep.1 count return value information
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-25 09:17:49 +01:00
Sami Kerola
3a21ef5580 docs: mention long options in man pgrep.1
This commit includes generic manual clean ups as well.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:17:02 +01:00
Craig Small
6bc22a379f pgrep: add -c option for counting number of matched proceesses
A patch from Debian.

Bug-Debian: http://bugs.debian.org/375791
Backported-by: Sami Kerola <kerolasa@iki.fi>
2011-12-18 22:30:41 +11:00
Sami Kerola
71d10d3a49 name change: procps -> procps-ng
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-04 20:50:12 +02:00
Jan Görig
039e2bb7df Manual pages fixes
Taken from Debian with small changes added

Authors: Craig Small <csmall@debian.org>, Brendan O'Dea <bod@debian.org>
2011-02-23 09:17:54 +01:00
albert
092d81f244 pgrep man page SEE ALSO updated 2004-07-15 16:27:38 +00:00
albert
7762f263e0 doc update 2002-10-23 21:37:28 +00:00
albert
501e740a31 new -o option: only the oldest that matches 2002-10-23 07:53:16 +00:00
csmall
03a9b5a30f procps 010114 2002-02-01 22:47:29 +00:00