summaryrefslogtreecommitdiff
path: root/usr.bin/pkill
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-10-10 14:25:43 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-10-10 14:25:43 +0000
commit965c1dbb3f3687eb56db683cb1126a49a7ab06b2 (patch)
treeee84d40eac4767d001997311590521fecbc77976 /usr.bin/pkill
parentf0984c1e8449c63f06a76d4b74ab691327619848 (diff)
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
Diffstat (limited to 'usr.bin/pkill')
-rw-r--r--usr.bin/pkill/pkill.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.bin/pkill/pkill.c b/usr.bin/pkill/pkill.c
index b03b7075d4c..4cc99b3649f 100644
--- a/usr.bin/pkill/pkill.c
+++ b/usr.bin/pkill/pkill.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pkill.c,v 1.36 2015/01/16 06:40:10 deraadt Exp $ */
+/* $OpenBSD: pkill.c,v 1.37 2015/10/10 14:25:42 deraadt Exp $ */
/* $NetBSD: pkill.c,v 1.5 2002/10/27 11:49:34 kleink Exp $ */
/*-
@@ -83,6 +83,7 @@ int pgrep;
int signum = SIGTERM;
int newest;
int oldest;
+char *pledge_choice = "stdio proc";
int quiet;
int inverse;
int longfmt;
@@ -154,6 +155,7 @@ main(int argc, char **argv)
if (strcmp(__progname, "pgrep") == 0) {
action = grepact;
+ pledge_choice = "stdio";
pgrep = 1;
} else {
action = killact;
@@ -273,6 +275,9 @@ main(int argc, char **argv)
if (plist == NULL)
errx(STATUS_ERROR, "kvm_getprocs() failed");
+ if (pledge(pledge_choice, NULL) == -1)
+ err(1, "pledge");
+
/*
* Allocate memory which will be used to keep track of the
* selection.