OpenBSD CVS

CVS log for src/usr.bin/pkill/pkill.c


[BACK] Up to [local] / src / usr.bin / pkill

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.43 / (download) - annotate - [select for diffs], Wed Sep 1 15:54:40 2021 UTC (2 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0, HEAD
Changes since 1.42: +2 -2 lines
Diff to previous 1.42 (colored)

A couple commands don't need sys/param.h, but they do need sys/signal.h

Revision 1.42 / (download) - annotate - [select for diffs], Mon Dec 16 19:21:17 2019 UTC (4 years, 5 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.41: +4 -7 lines
Diff to previous 1.41 (colored)

Delete tests for P_THREAD that predate the existence of
KERN_PROC_SHOW_THREADS and have been rendered superfluous by it.
Similarly, some P_SYSTEM tests can be deleted or pushed to the
kernel by using KERN_PROC_ALL instead of KERN_PROC_KTHREAD.

ok visa@ mpi@

Revision 1.41 / (download) - annotate - [select for diffs], Fri Jun 28 13:35:02 2019 UTC (4 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.40: +2 -2 lines
Diff to previous 1.40 (colored)

When system calls indicate an error they return -1, not some arbitrary
value < 0.  errno is only updated in this case.  Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.

Revision 1.40 / (download) - annotate - [select for diffs], Sun Sep 16 02:44:06 2018 UTC (5 years, 8 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.39: +7 -7 lines
Diff to previous 1.39 (colored)

Use uid_from_user(3) and gid_from_group(3) in utilities that
do repeated lookups.  OK tb@

Revision 1.39 / (download) - annotate - [select for diffs], Mon Oct 10 02:22:59 2016 UTC (7 years, 7 months ago) by gsoares
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.38: +17 -20 lines
Diff to previous 1.38 (colored)

- mark delim variable as const. it is a literal string;
- no need to declare main() prototype;
- mark all functions as static;
- add __dead marker to usage(), since it doesn't return;
- zap extern *optarg/optind in main(), It is already done in unistd.h;
- return from main instead of exit(3) that enables stack protector;
- fix err() eval in pledge()s error path.

OK millert@

Revision 1.38 / (download) - annotate - [select for diffs], Sun Oct 11 03:08:20 2015 UTC (8 years, 7 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.37: +10 -5 lines
Diff to previous 1.37 (colored)

fix a regression spotted by chris@.  the -f and -I arguments fetch process
arguments using kvm_getargs, after the pledge() has been made.  someone
brave should refactor this, hoisting the argument fetching to between
kvm_getprocs() and pledge() - storing the argument data as neccessary.
the current situation is also a race -- it fetches the data twice.

Revision 1.37 / (download) - annotate - [select for diffs], Sat Oct 10 14:25:42 2015 UTC (8 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.36: +6 -1 lines
Diff to previous 1.36 (colored)

pkill has to get all the getopt, getpwuid, libkvm stuff out of the way
first.  it can pledge to "stdio" (pgrep case) or "stdio proc" (pkill case)
before parsing and matching the expression.
ok doug

Revision 1.36 / (download) - annotate - [select for diffs], Fri Jan 16 06:40:10 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.35: +3 -3 lines
Diff to previous 1.35 (colored)

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)

Revision 1.35 / (download) - annotate - [select for diffs], Wed May 7 01:27:42 2014 UTC (10 years ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.34: +2 -3 lines
Diff to previous 1.34 (colored)

calloc, from peter malone

Revision 1.34 / (download) - annotate - [select for diffs], Tue Nov 12 13:54:51 2013 UTC (10 years, 6 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.33: +3 -1 lines
Diff to previous 1.33 (colored)

simpler prototype repairs

Revision 1.33 / (download) - annotate - [select for diffs], Sun Sep 22 17:28:34 2013 UTC (10 years, 7 months ago) by guenther
Branch: MAIN
Changes since 1.32: +2 -2 lines
Diff to previous 1.32 (colored)

Stop merging the per-thread and per-process flags when reporting
them via sysctl(KERN_PROC).  In struct kinfo_proc the per-process
flags move to p_psflags, leaving the per-thread flags in p_flags.
Flag descriptions in ps(1) updated to be less obtuse.

discussed with matthew@ some time ago; ok jca@, manpage bits ok jmc@

Revision 1.32 / (download) - annotate - [select for diffs], Mon Jun 3 04:17:37 2013 UTC (10 years, 11 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.31: +62 -27 lines
Diff to previous 1.31 (colored)

-I to confirm pkills. ok many

Revision 1.31 / (download) - annotate - [select for diffs], Wed Dec 12 22:25:21 2012 UTC (11 years, 5 months ago) by halex
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.30: +22 -12 lines
Diff to previous 1.30 (colored)

properly handle the case where a process has disappeared in between grep'ing
and printing it

discussed with and ok millert@

Revision 1.30 / (download) - annotate - [select for diffs], Tue Aug 21 10:32:38 2012 UTC (11 years, 9 months ago) by ajacoutot
Branch: MAIN
Changes since 1.29: +3 -3 lines
Diff to previous 1.29 (colored)

Missing "-q" in usage().

ok espie@

Revision 1.29 / (download) - annotate - [select for diffs], Tue Aug 21 06:28:36 2012 UTC (11 years, 9 months ago) by espie
Branch: MAIN
Changes since 1.28: +10 -4 lines
Diff to previous 1.28 (colored)

add -q "silent" option similar to grep
okay ajacoutot@, guenther@

Revision 1.28 / (download) - annotate - [select for diffs], Tue Jul 10 12:48:08 2012 UTC (11 years, 10 months ago) by halex
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.27: +4 -7 lines
Diff to previous 1.27 (colored)

make pkill -l print the proper processes also when the invert (-v)
flag is passed

ok lum@

Revision 1.27 / (download) - annotate - [select for diffs], Sat Apr 21 03:14:50 2012 UTC (12 years, 1 month ago) by guenther
Branch: MAIN
Changes since 1.26: +1 -3 lines
Diff to previous 1.26 (colored)

Remove a check made superfluous by the KERN_PROC_SHOW_THREADS flag.
This lets new binaries work (at least w/o the -H option) with old kernels.

ok pirofti@ deraadt@

Revision 1.26 / (download) - annotate - [select for diffs], Thu Apr 12 14:59:19 2012 UTC (12 years, 1 month ago) by pirofti
Branch: MAIN
Changes since 1.25: +3 -1 lines
Diff to previous 1.25 (colored)

Add per thread accounting, mainly for usage & friends.

This expands the already bloated FILL_KPROC macro to take an extra
parameter that indicates if the callee is a thread or a process.

The userland bits are adjusted accordingly and ps(1) and top(1) now
display per thread usage times when -H is used.

Also pkill(1) had to be adjusted so that duplicates don't pop up.

libkvm does basically the same thing as the kernel bits.

Okay guenther@.

Revision 1.25 / (download) - annotate - [select for diffs], Tue Mar 13 09:44:49 2012 UTC (12 years, 2 months ago) by sthen
Branch: MAIN
Changes since 1.24: +7 -4 lines
Diff to previous 1.24 (colored)

Teach pgrep/pkill to only match processes, not threads. ok guenther@

Revision 1.24 / (download) - annotate - [select for diffs], Thu Mar 1 13:04:29 2012 UTC (12 years, 2 months ago) by lum
Branch: MAIN
Changes since 1.23: +2 -6 lines
Diff to previous 1.23 (colored)

Remove unused variable. Added in 1.20 by me.

Revision 1.23 / (download) - annotate - [select for diffs], Thu Feb 16 21:25:35 2012 UTC (12 years, 3 months ago) by jmc
Branch: MAIN
Changes since 1.22: +2 -2 lines
Diff to previous 1.22 (colored)

exit usage() with STATUS_BADUSAGE rather than STATUS_ERROR, per the man page;

fix proposed by lum actually happened in netbsd -r1.16, some 6 years ago;
ok lum

Revision 1.22 / (download) - annotate - [select for diffs], Wed Feb 15 08:19:30 2012 UTC (12 years, 3 months ago) by jmc
Branch: MAIN
Changes since 1.21: +3 -3 lines
Diff to previous 1.21 (colored)

avoid usage() warping onto the next line;

Revision 1.21 / (download) - annotate - [select for diffs], Thu Feb 9 20:04:35 2012 UTC (12 years, 3 months ago) by markus
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.20: +27 -5 lines
Diff to previous 1.20 (colored)

restrict pkill/pgrep to the routing domain specified by -T; ok henning@, mpf@

Revision 1.20 / (download) - annotate - [select for diffs], Tue Jan 17 04:27:20 2012 UTC (12 years, 4 months ago) by lum
Branch: MAIN
Changes since 1.19: +8 -4 lines
Diff to previous 1.19 (colored)

Allow pkill to use the -l option. This displays which processes have been
signalled using the "Long" format, like pgrep.

Original diff from FreeBSD, modified somewhat on tech@, with feedback from nicm@

Man page input from jmc@

Revision 1.19 / (download) - annotate - [select for diffs], Sun Apr 10 03:20:59 2011 UTC (13 years, 1 month ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.18: +12 -12 lines
Diff to previous 1.18 (colored)

Switch back from KERN_PROC2/kinfo_proc2 to KERN_PROC/kinfo_proc now
that we've got name we want for the API we want

"ZAP!" deraadt@

Revision 1.18 / (download) - annotate - [select for diffs], Tue Oct 27 23:59:41 2009 UTC (14 years, 6 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8, OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.17: +1 -5 lines
Diff to previous 1.17 (colored)

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable).  these days, people use source.  these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms

Revision 1.17 / (download) - annotate - [select for diffs], Thu Jun 26 05:42:21 2008 UTC (15 years, 10 months ago) by ray
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6, OPENBSD_4_5_BASE, OPENBSD_4_5, OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.16: +2 -9 lines
Diff to previous 1.16 (colored)

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@

Revision 1.16 / (download) - annotate - [select for diffs], Thu Feb 7 15:38:07 2008 UTC (16 years, 3 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.15: +24 -11 lines
Diff to previous 1.15 (colored)

Add add -o flag to pkill/pgrep like on Solaris and Linux.
OK jmc@ henning@ oga@ mikeb@

Revision 1.15 / (download) - annotate - [select for diffs], Tue Sep 19 05:52:23 2006 UTC (17 years, 8 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2, OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.14: +3 -3 lines
Diff to previous 1.14 (colored)

Use S_IS* macros insted of masking with S_IF* flags. The latter may
have multiple bits set, which lead to surprising results. Spotted by
Paul Stoeber, more to come. ok millert@ pedro@ jaredy@ djm@

Revision 1.14 / (download) - annotate - [select for diffs], Sat Jul 16 11:48:46 2005 UTC (18 years, 10 months ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_4_0, OPENBSD_3_9_BASE, OPENBSD_3_9, OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.13: +4 -4 lines
Diff to previous 1.13 (colored)

sort options and sync usage();

Revision 1.13 / (download) - annotate - [select for diffs], Fri May 20 07:26:49 2005 UTC (19 years ago) by otto
Branch: MAIN
Changes since 1.12: +3 -3 lines
Diff to previous 1.12 (colored)

Don't print an empty line when no match is found in pgrep mode.
ok millert@ robert@

Revision 1.12 / (download) - annotate - [select for diffs], Mon Apr 11 20:25:23 2005 UTC (19 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.11: +5 -3 lines
Diff to previous 1.11 (colored)

handle snprintf return value overflow case; ok otto

Revision 1.11 / (download) - annotate - [select for diffs], Sun Mar 27 20:56:47 2005 UTC (19 years, 1 month ago) by robert
Branch: MAIN
Changes since 1.10: +6 -10 lines
Diff to previous 1.10 (colored)

revert r1.9; this one needs more discussion

Revision 1.10 / (download) - annotate - [select for diffs], Sun Mar 27 14:50:09 2005 UTC (19 years, 1 month ago) by robert
Branch: MAIN
Changes since 1.9: +10 -6 lines
Diff to previous 1.9 (colored)

add a -i option to ignore case distinctions in the process match;
From: NetBSD; ok millert@

Revision 1.9 / (download) - annotate - [select for diffs], Wed Mar 2 21:45:53 2005 UTC (19 years, 2 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.8: +4 -6 lines
Diff to previous 1.8 (colored)

Report non-existing user or groupname correctly. From David Brownlee
<abs@netbsd>. ok millert@

Revision 1.8 / (download) - annotate - [select for diffs], Fri Feb 11 17:17:45 2005 UTC (19 years, 3 months ago) by millert
Branch: MAIN
Changes since 1.7: +14 -10 lines
Diff to previous 1.7 (colored)

Fix -d option; it should print a newline at EOL, not the specified delimeter.
Problem found and OK by robert@

Revision 1.7 / (download) - annotate - [select for diffs], Wed Dec 29 19:40:36 2004 UTC (19 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.6: +7 -3 lines
Diff to previous 1.6 (colored)

handle snprintf -1; otto ok

Revision 1.6 / (download) - annotate - [select for diffs], Thu Jul 15 17:15:33 2004 UTC (19 years, 10 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.5: +3 -3 lines
Diff to previous 1.5 (colored)

Don't print a warning if kill(2) returns ESRCH since the process may have
died on its own in the time between when the process list was consulted
and when we do the actual kill.  This fixes an annoyance for privsep
processes (and others) where when you kill one the others die by themselves.

Revision 1.5 / (download) - annotate - [select for diffs], Thu Jul 15 13:55:10 2004 UTC (19 years, 10 months ago) by mpech
Branch: MAIN
Changes since 1.4: +4 -7 lines
Diff to previous 1.4 (colored)

Skip SYSTEM and ourown proccess on every loop.

millert@, otto@

Revision 1.4 / (download) - annotate - [select for diffs], Thu Jun 24 18:04:45 2004 UTC (19 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.3: +20 -14 lines
Diff to previous 1.3 (colored)

When given multiple processes to kill, keep going if we are unable to kill
one (previously it would error out and not kill the remaining ones).
OK deraadt@

Revision 1.3 / (download) - annotate - [select for diffs], Fri Mar 12 00:19:48 2004 UTC (20 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.2: +6 -6 lines
Diff to previous 1.2 (colored)

knf

Revision 1.2 / (download) - annotate - [select for diffs], Wed Jan 7 02:17:31 2004 UTC (20 years, 4 months ago) by millert
Branch: MAIN
Changes since 1.1: +47 -54 lines
Diff to previous 1.1 (colored)

Convert back to using kvm_getproc2() and friends now that libkvm
supports it.

Revision 1.1 / (download) - annotate - [select for diffs], Tue Jan 6 20:07:49 2004 UTC (20 years, 4 months ago) by millert
Branch: MAIN

pkill/pgrep from NetBSD with changes to use kvm_getprocs().  Selecting
on session ID does not current work but that will change once the
kernel supports the KERN_PROC2 sysctl and pkill/pgrep is modified
to use kvm_getproc2().  OK deraadt@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.