Commit Graph

42 Commits

Author SHA1 Message Date
Yaroslav Tykhiy
6c43fb6f9e Tell in a comment that the symlinks from /usr/bin are
for compatibility with other OS types, too.

Pointed out by:		gad
2006-08-20 04:25:20 +00:00
Yaroslav Tykhiy
55416ca8f7 Install pkill(1), aka pgrep(1), to /bin so that rc scripts
can use this small and nifty utility.  Create compatibility
symlinks from /usr/bin for the time being to avoid breaking
custom scripts relying on the hardcoded path to the utility.

If pkill(1) takes root, its source should be repocopied some
day to src/bin.

Idea by:	des
Discussed with:	brooks (in cvs-src and cvs-all)
2006-08-19 08:24:01 +00:00
Ruslan Ermilov
4e9e907d63 -mdoc sweep. 2005-11-18 10:36:29 +00:00
Pawel Jakub Dawidek
53ff091d14 Sync as close as possible with NetBSD.
This includes fixes and cleanups listed below:

- If a process dissappears while we are signalling it, don't count it as a
  match/error.
- Better handling of errors and messages.
- Downgrade failure to kill(2) (other than ESRCH) from fatal error to a
  warning; otherwise processing aborts and possibly matching killees would
  remain unsignalled. This makes pkill match the Solaris behavior.
- Exit with 2 on usage errors as documented.

Obtained from:	NetBSD
Glanced at by:	maintainer (gad) [a bit different version of this patch]
2005-11-16 11:03:00 +00:00
Pawel Jakub Dawidek
b77640621b I often find myself doing:
% pgrep <something> [to verify which processes match]
	% pkill <something>

To speed such operation up, add -I option which works like rm(1)'s -i
option (unfortunately -i is already used in pkill(1)), ie. pkill will
ask for confirmation before killing each matching process.

After adding -j, -F, -i, -S, -o and -L options and other improvements,
I think I can add myself to the copyright header.

Glanced at by:	maintainer (gad)
2005-11-16 10:36:44 +00:00
Pawel Jakub Dawidek
70ffddc463 Revert previous behaviour of '-F' option and add '-L' option, which will
tell pkill(1)/pgrep(1) to try to flock(2) pidfile before reading PID from
there.

Discussed with:	jhb, gad
2005-08-25 20:10:47 +00:00
Pawel Jakub Dawidek
712bf6af16 Modify '-F' option to work nicely with pidfile(3) - a pidfile given as
an argument has to be locked.
2005-08-24 19:38:28 +00:00
Ruslan Ermilov
39c59153e9 Markup and wording fixes.
Approved by:	re (blanket)
2005-06-14 11:50:53 +00:00
Pawel Jakub Dawidek
d0cf19a161 Whitespace fixes. 2005-03-20 11:47:44 +00:00
Pawel Jakub Dawidek
0a5f326cd2 - Introduce an '-o' option which allows to match oldest of the matching
processes.
  This option can be also found in Solaris and Linux.
- Use timercmp(9) macro for timeval comparsion.
- Include time.h directly, don't depend on stat.h doing it for us.

Reviewed by:	gad (first point)
MFC after:	3 days
2005-03-20 11:42:26 +00:00
Pawel Jakub Dawidek
d054f5d7cd - Introduce '-S' option which allows to match system processes (pgrep only).
- Rename IS_KERNPROC() macro to PSKIP() and extend its functionality.
  Now it'll skip calling process and system processes when -S is not given.
  As a side effect it fixes '-n' option. Before it was always matching
  calling process (because of missing 'if (kp->ki_pid == mypid)' check)
  and after that, calling process was ignored.
- When '-l' option is given and there are no arguments, use p_comm as an
  arguments list (this is helpful for kernel threads matching).

Reviewed by:	gad
MFC after:	3 days
2005-03-20 11:30:26 +00:00
Pawel Jakub Dawidek
b94b78867e Sort options properly.
Reviewed by:	gad
MFC after:	3 days
2005-03-20 11:17:06 +00:00
Pawel Jakub Dawidek
46a4b46cd7 Add a -i option to ignore case in the process match.
Obtained from:	NetBSD
Reviewed by:	gad
MFC after:	3 days
2005-03-20 11:12:13 +00:00
Pawel Jakub Dawidek
87a8221aeb Add and document '-F' option which allows to use file where PID is stored
for matching.

Reviewed by:	gad
MFC after:	3 days
2005-03-20 11:03:11 +00:00
Pawel Jakub Dawidek
2b0a135497 Add and document '-j' option which allows to match processes based on its
jail ID.

Reviewed by:	gad
MFC after:	3 days
2005-03-20 10:53:54 +00:00
Xin LI
b2253a33dc If a user or group is not known, report the problem user/group, rather than
the first user/group. Caused huge fun in error messages from large script.
Old:	pgrep -u root,NoSuchUser,daemon	-> pgrep: unknown user `root'
Now:	pgrep -u root,NoSuchUser,daemon	-> pgrep: unknown user `NoSuchUser'

Obtained from:	NetBSD (rev. 1.8)
MFC After:	1 week (if re@ would have approved this)
2005-03-03 02:17:20 +00:00
Ruslan Ermilov
832b0b55ac Removed bitrot. 2004-11-13 17:12:22 +00:00
Garance A Drosehn
47208ac20a Document the fact that matching against a process command-name will
only work on the first MAXCOMLEN (19) characters of that name.

Noticed by:	Peter Holm
2004-08-16 04:49:43 +00:00
Stefan Farfeleder
1deda7df19 Don't forget the arguments for -M and -N in the DESCRIPTION section. 2004-07-18 23:05:31 +00:00
Tim J. Robbins
4ff2396545 Respect locale settings from the environment. 2004-07-15 08:13:56 +00:00
Poul-Henning Kamp
f3732fd15b Second half of the dev_t cleanup.
The big lines are:
	NODEV -> NULL
	NOUDEV -> NODEV
	udev_t -> dev_t
	udev2dev() -> findcdev()

Various minor adjustments including handling of userland access to kernel
space struct cdev etc.
2004-06-17 17:16:53 +00:00
Ruslan Ermilov
a12d0a1aee Added pgrep to the SYNOPSIS.
Fixed SYNOPSIS.
Fixed markup nits.
2004-05-19 10:46:56 +00:00
Garance A Drosehn
c3f750cfbf Use KERN_PROC_PROC instead of KERN_PROC_ALL on the call to kvm_getprocs(),
so we get one line per process instead of one for each kernel-thread.

Noticed by:	ache & tjr
2004-03-30 15:10:50 +00:00
Garance A Drosehn
c3e741f776 bde also tells me that he is confident that P_SYSTEM will not work
any better on 4.x than it does on 5.2. If that's true then there
is no point to the __FreeBSD_version check that I had added.
2004-03-27 06:49:57 +00:00
Garance A Drosehn
b643171bdb Some style(9)-ish improvements, courtesy of bde.
Noticed by:	bde
2004-03-27 05:40:31 +00:00
Garance A Drosehn
3d7fb10b5f Remove the _PATH_DEVNULL setting for "swapf". From the kvm_open(3)
man page:  The swapfile argument is currently unused.

Noticed by:	ru
2004-03-26 19:29:57 +00:00
Garance A Drosehn
47fc3041b2 Remove the NEED_KMEM support meant for FreeBSD 3.x. This base-system
version isn't going to be committed to that branch...

Noticed by:	des
2004-03-26 18:02:40 +00:00
Garance A Drosehn
d5ddb9bf52 Switch to checking P_KTHREAD instead of P_SYSTEM when deciding what
"system processes" to always ignore.  Based on my testing with `-D',
I am pretty sure this is what we want for 5.x-current.  If my thinking
is wrong, this also makes it easier to switch to a different check.
2004-03-26 17:51:49 +00:00
Ruslan Ermilov
f9a480abb1 Avoid the manpage layering violation and low-level implementation
details of libkvm, and just tell what the getbootfile(3) function
will return, by using the text from netstat(1) and dmesg(8).
2004-03-26 08:54:27 +00:00
Ruslan Ermilov
411ec5a7be Correct the description of options -N and -M to match reality. 2004-03-26 08:47:01 +00:00
Ruslan Ermilov
73bfeb89ca Apply style.Makefile(5). 2004-03-26 07:44:49 +00:00
Garance A Drosehn
f72f4d3a9c Send those -Debug messages to stderr, not stdout... 2004-03-26 02:20:52 +00:00
Garance A Drosehn
c44047c7a8 Add a debugging option, as I don't understand something that I'm seeing.
(this is a probably temporary option, and is not to be documented)
2004-03-26 01:43:19 +00:00
Garance A Drosehn
5def7269c2 Remove a redundant check against mypid (the check is done later, in
the "Take the appropriate action" section).

Obtained from:	the sysutils/pkill port
2004-03-26 01:30:15 +00:00
Garance A Drosehn
eb6d801134 Add a cast to get this to compile with WARNS=5 on sparc64. This is
needed because off_t == __int64_t, while size_t == __uint64_t.  This
also compiles with WARNS=5 on amd64, but I haven't tested the other
platforms yet.
2004-03-26 00:36:27 +00:00
Garance A Drosehn
ae1a248822 Fixes so this will compile with WARNS=5 on i386. 2004-03-26 00:15:20 +00:00
Garance A Drosehn
7ee9bb7817 Fix two cosmetic style(9) issues. 2004-03-25 23:35:14 +00:00
Garance A Drosehn
a6b60aa310 Add a comment for when these utilities were added to FreeBSD, and add
a cross-reference to killall(1).
2004-03-25 23:32:12 +00:00
Garance A Drosehn
998c10ebd9 Add -M' and -N' options to pkill' and pgrep', similar to
what are supported in `ps':

  -M  Extract values associated with the name list from the
      specified core instead of the default /dev/kmem.
  -N  Extract the name list from the specified system instead
      of the default /kernel.

Written by:	Mario Sergio Fujikawa Ferreira <lioux@FreeBSD.org>
Obtained from:	the sysutils/pkill port
2004-03-25 23:19:16 +00:00
Garance A Drosehn
69fd9fbfbc Use the correct type for some casts, thus avoiding a few warning messages
when compiling with WARNS=3

Written by:	Mario Sergio Fujikawa Ferreira <lioux@FreeBSD.org>
Obtained from:	the sysutils/pkill port
2004-03-25 22:08:52 +00:00
Garance A Drosehn
1b58b96b64 Change some routine and variable names to match the FreeBSD system.
Written by:	Mario Sergio Fujikawa Ferreira <lioux@FreeBSD.org>
Obtained from:	the sysutils/pkill port
2004-03-25 21:58:56 +00:00
Garance A Drosehn
0ddb37d879 Add the pkill' and pgrep' commands from NetBSD. This is the source
straight from NetBSD (except to add the RCS-ID lines for FreeBSD).
These will probably require a few updates before they are added to
the FreeBSD buildworld.  I might MFC these to 4.x-stable after 4.10.

Discussed on:	freebsd-arch
Obtained from:	NetBSD (and OpenBSD also has these)
2004-03-25 19:08:48 +00:00