summaryrefslogtreecommitdiffstats
path: root/usr.bin/pkill
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/pkill')
-rw-r--r--usr.bin/pkill/pkill.121
-rw-r--r--usr.bin/pkill/pkill.c32
2 files changed, 44 insertions, 9 deletions
diff --git a/usr.bin/pkill/pkill.1 b/usr.bin/pkill/pkill.1
index 7db3307..cf202fd 100644
--- a/usr.bin/pkill/pkill.1
+++ b/usr.bin/pkill/pkill.1
@@ -36,7 +36,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd November 16, 2005
+.Dd November 23, 2006
.Dt PKILL 1
.Os
.Sh NAME
@@ -146,7 +146,12 @@ Ignore case distinctions in both the process table and the supplied pattern.
Restrict matches to processes inside jails with a jail ID in the comma-separated
list
.Ar jid .
-The value zero is taken to mean any jail ID.
+The value
+.Dq Li any
+matches processes in any jail.
+The value
+.Dq Li none
+matches processes not in jail.
.It Fl l
Long output.
Print the process name in addition to the process ID for each matching
@@ -240,6 +245,18 @@ Invalid options were specified on the command line.
.It 3
An internal error occurred.
.El
+.Sh COMPATIBILITY
+Historically the option
+.Dq Fl j Li 0
+means any jail, although in other utilities such as
+.Xr ps 1
+jail ID
+.Li 0
+has the opposite meaning, not in jail.
+Therefore
+.Dq Fl j Li 0
+is deprecated, and its use is discouraged in favor of
+.Dq Fl j Li any .
.Sh SEE ALSO
.Xr kill 1 ,
.Xr killall 1 ,
diff --git a/usr.bin/pkill/pkill.c b/usr.bin/pkill/pkill.c
index 94bc70c..2547744 100644
--- a/usr.bin/pkill/pkill.c
+++ b/usr.bin/pkill/pkill.c
@@ -84,6 +84,7 @@ enum listtype {
LT_GROUP,
LT_TTY,
LT_PGRP,
+ LT_JID,
LT_SID
};
@@ -235,7 +236,7 @@ main(int argc, char **argv)
cflags |= REG_ICASE;
break;
case 'j':
- makelist(&jidlist, LT_GENERIC, optarg);
+ makelist(&jidlist, LT_JID, optarg);
criteria = 1;
break;
case 'l':
@@ -451,12 +452,12 @@ main(int argc, char **argv)
}
SLIST_FOREACH(li, &jidlist, li_chain) {
- if (kp->ki_jid > 0) {
- if (li->li_number == 0)
- break;
- if (kp->ki_jid == (int)li->li_number)
- break;
- }
+ /* A particular jail ID, including 0 (not in jail) */
+ if (kp->ki_jid == (int)li->li_number)
+ break;
+ /* Any jail */
+ if (kp->ki_jid > 0 && li->li_number == -1)
+ break;
}
if (SLIST_FIRST(&jidlist) != NULL && li == NULL) {
selected[i] = 0;
@@ -636,6 +637,14 @@ makelist(struct listhead *head, enum listtype type, char *src)
if (li->li_number == 0)
li->li_number = getsid(mypid);
break;
+ case LT_JID:
+ if (li->li_number < 0)
+ errx(STATUS_BADUSAGE,
+ "Negative jail ID `%s'", sp);
+ /* For compatibility with old -j */
+ if (li->li_number == 0)
+ li->li_number = -1; /* any jail */
+ break;
case LT_TTY:
usage();
/* NOTREACHED */
@@ -683,6 +692,15 @@ makelist(struct listhead *head, enum listtype type, char *src)
li->li_number = st.st_rdev;
break;
+ case LT_JID:
+ if (strcmp(sp, "none") == 0)
+ li->li_number = 0;
+ else if (strcmp(sp, "any") == 0)
+ li->li_number = -1;
+ else if (*ep != '\0')
+ errx(STATUS_BADUSAGE,
+ "Invalid jail ID `%s'", sp);
+ break;
default:
usage();
}
OpenPOWER on IntegriCloud