Commit Graph

49 Commits

Author SHA1 Message Date
Sami Kerola
b2ebca4a60 pgrep: fix potential null derefences [smatch scan]
pgrep.c:137 split_list(19) error: potential null derefence 'list'.
pgrep.c:540 select_procs(106) error: potential null derefence 'list'.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-05 21:13:36 +01:00
Sami Kerola
bc974b3c33 pkill: enable displaying what is killed
Add new command line options -e, --echo to display what is
killed. Cost of this change is greater run time memory footprint,
because an union had to be changed to struct to allow name and
pid printing which what I as an user would expect to see in
verbose kill output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-21 13:44:00 +01:00
Sami Kerola
12dce9f83b pgrep: fix compiler warning
pgrep.c:786:4: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'int' [-Wformat]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-21 12:15:41 +01:00
Sami Kerola
3489b9343e pkill: fix error printing
Print correct pid number of process that was where not killed
because of kill was not successful. Incorrect behaviour before
this fix is bello.

-- snip
$ ps -elf | grep dh[c]
1 S root      1409     1  0  80   0 -  1782 poll_s 02:01 ?        00:00:00 dhclient wlan0
$ pkill dhc
pkill: killing pid 1 failed: Operation not permitted
-- snip

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-21 12:15:40 +01:00
Sami Kerola
62316be69a pgrep: correction to usage output
Signed-off-by: Sami Kerola <sami.kerola@tomtom.com>
2012-01-06 00:17:44 +11:00
Craig Small
fb11e1fe0a Changed the err and warns to macros
err and warn are BSD format but they are not recommended by library
developers.  However their consiseness is useful!

The solution is to use some macros that create xerr etc which then
just map to the error() function.  The next problem is error() uses
program_invocation_name so we set this to program_invovation_short_name

This is a global set but seems to be the convention (or at least errors
are on the short name only) used everywhere else.
2012-01-03 18:48:43 +11:00
Sami Kerola
c3405fab1a translations: group usage texts
Reference: http://www.freelists.org/post/procps/backporting,5
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-02 16:29:03 +11:00
Sami Kerola
46d5d44734 pgrep: exit with error message instead of usage()
Printing usage() output at error is too noisy.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:54 +01:00
Sami Kerola
0022b6ec5d nls: improve translations and provide translator help comments
Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:54 +01:00
Sami Kerola
c862a4caa5 nls: add functions which take translations to be used
Add the following three functions to most of the commands.

setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);

Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
4bfc4a00fb pgrep: use libc error printing facilities
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:50 +01:00
Sami Kerola
1ef14f4bf9 includes: add xalloc.h to unify memory allocations
The xalloc.h provides necessary error checking.

Signed-off-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:50 +01:00
Sami Kerola
ad6054b372 pgrep: add gettext support
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:17:04 +01:00
Sami Kerola
4581ac2240 pgrep: add long options & new usage
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:17:02 +01:00
Jan Christoph Nordholz
c73a449482 pgrep: distinguish between invalid commandline parameters and '-?'
A patch from Debian.

Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=413383
Backported-by: Sami Kerola <kerolasa@iki.fi>
2011-12-18 22:38:03 +11:00
Craig Small
551d7e4114 pgrep: fix compiler warning saved_start_time might be used uninitialized
A patch from Debian.

Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=197342
Backported-by: Sami Kerola <kerolasa@iki.fi>
2011-12-18 22:34:11 +11: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
Craig Small
618c52167b reversed the frees added to pgrep 2011-11-23 21:31:43 +11:00
Sami Kerola
2e96bc3771 pgrep: core dropped nearly always
The do_regcomp() tries to free command line argument.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-11-20 22:16:35 +01:00
Jim Warner
b23baee15c redhat analysis: pgrep 2011-10-15 08:26:28 +02:00
albert
e5b2b8614d pgrep: usage error should exit with 2 2007-05-28 00:16:39 +00:00
albert
47d33e7ed4 g is criteria 2006-06-24 20:12:29 +00:00
albert
7e2f073fbd better -L support 2006-06-23 03:18:12 +00:00
albert
6baa2fd34e FreeBSD -F and -L options (but -L may be useless) with sucky error messages 2006-06-21 05:45:16 +00:00
albert
93ed75edc9 correct description of some currently-foreign options 2006-06-21 04:41:58 +00:00
albert
492acac001 pgrep cleanup 2006-06-21 04:18:02 +00:00
albert
ffc32c6f8b fix more of the pgrep memory-related brokenness 2006-06-18 23:19:30 +00:00
albert
5b13bb93c7 new foreign-OS research noted 2006-06-18 20:55:02 +00:00
albert
5c591b836f fix "ps sm" bug involving 1-thread-proc optimization 2006-06-17 04:14:57 +00:00
albert
29cbc63561 fputs instead of fprintf 2005-10-30 23:45:47 +00:00
albert
d89cf44470 pkill should be quiet about processes that have gone away 2004-10-19 18:04:31 +00:00
albert
9e52b5aa29 sort cmd args and document OpenBSD differences 2004-07-21 14:27:56 +00:00
albert
c462dcfad5 ps thread support 2003-09-20 08:29:55 +00:00
albert
70599c3d3f last bits 2002-12-21 14:13:33 +00:00
albert
3e67b58ec2 satisfy GPL section 2a and LGPL section 2b name+date requirement 2002-12-15 00:30:17 +00:00
albert
b657e7e08a NORETURN 2002-12-09 07:53:09 +00:00
albert
eefbbef08b ChangeLog 2002-12-08 20:28:40 +00:00
albert
7ac9a0e1f5 present for Jim 2002-12-03 09:07:59 +00:00
albert
f40af35b77 c99 2002-11-25 21:36:43 +00:00
albert
19e565177b pgrep dead code 2002-11-25 21:14:36 +00:00
albert
c941d496a2 reorder pgrep functions, c99 vmstat 2002-11-25 21:12:25 +00:00
albert
501e740a31 new -o option: only the oldest that matches 2002-10-23 07:53:16 +00:00
albert
81a4a3d281 gcc 3.0 warnings 2002-10-12 04:25:57 +00:00
albert
e4d350522e mention -a 2002-10-09 04:28:48 +00:00
csmall
cca86db7ba added version stuff for kill and pgrep, tried to understand alberts groff and failed 2002-10-03 23:08:14 +00:00
albert
84ed57020d ifdef and cruft removal 2002-09-30 07:11:30 +00:00
albert
bce2da1f9a 64-bit time for Linux 2.5.xx 2002-05-28 04:18:55 +00:00
csmall
e4c67b2724 Put most of the Debian patches in
added a lot of cvsignore files
2002-02-01 23:40:38 +00:00
csmall
03a9b5a30f procps 010114 2002-02-01 22:47:29 +00:00