diff options
author | mike <mike@FreeBSD.org> | 2003-04-09 03:04:12 +0000 |
---|---|---|
committer | mike <mike@FreeBSD.org> | 2003-04-09 03:04:12 +0000 |
commit | 6067525913c2a13f7785f6d88dc81df85cde5812 (patch) | |
tree | 058bbdc564bcc891a28e1adb5f67a45e806274e2 /usr.bin/killall | |
parent | 79d60009e2bdcbd2cc1dacebff7139856d04ee1a (diff) | |
download | FreeBSD-src-6067525913c2a13f7785f6d88dc81df85cde5812.zip FreeBSD-src-6067525913c2a13f7785f6d88dc81df85cde5812.tar.gz |
o Add jls(8) for listing active jails.
o Add jexec(8) to execute a command in an existing jail.
o Add -j option for killall(1) to kill all processes in a specified
jail.
o Add -i option to jail(8) to output jail ID of newly created jail.
Diffstat (limited to 'usr.bin/killall')
-rw-r--r-- | usr.bin/killall/killall.1 | 9 | ||||
-rw-r--r-- | usr.bin/killall/killall.c | 23 |
2 files changed, 28 insertions, 4 deletions
diff --git a/usr.bin/killall/killall.1 b/usr.bin/killall/killall.1 index 9c81346..3614e3f 100644 --- a/usr.bin/killall/killall.1 +++ b/usr.bin/killall/killall.1 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 25, 1995 +.Dd April 8, 2003 .Os .Dt KILLALL 1 .Sh NAME @@ -39,6 +39,7 @@ .Op Fl m .Op Fl s .Op Fl z +.Op Fl j Ar jid .Op Fl u Ar user .Op Fl t Ar tty .Op Fl c Ar procname @@ -89,6 +90,9 @@ The signal may be specified either as a name (with or without a leading .Dv SIG ) , or numerically. +.It Fl j Ar jid +Kill processes in the jail specified by +.Ar jid . .It Fl u Ar user Limit potentially matching processes to those belonging to the specified @@ -133,7 +137,8 @@ Diagnostic messages will only be printed if requested by options. .Sh SEE ALSO .Xr kill 1 , -.Xr sysctl 3 +.Xr sysctl 3 , +.Xr jail 8 .Sh HISTORY The .Nm diff --git a/usr.bin/killall/killall.c b/usr.bin/killall/killall.c index b1fcc25..4c2b06a 100644 --- a/usr.bin/killall/killall.c +++ b/usr.bin/killall/killall.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> +#include <sys/jail.h> #include <sys/stat.h> #include <sys/user.h> #include <sys/sysctl.h> @@ -49,7 +50,9 @@ static void __dead2 usage(void) { - fprintf(stderr, "usage: killall [-l] [-v] [-m] [-sig] [-u user] [-t tty] [-c cmd] [cmd]...\n"); + fprintf(stderr, "usage: killall [-l] [-v] [-m] [-sig] [-j jid]\n"); + fprintf(stderr, + " [-u user] [-t tty] [-c cmd] [cmd]...\n"); fprintf(stderr, "At least one option or argument to specify processes must be given.\n"); exit(1); } @@ -110,6 +113,7 @@ main(int ac, char **av) int vflag = 0; int sflag = 0; int dflag = 0; + int jflag = 0; int mflag = 0; int zflag = 0; uid_t uid = 0; @@ -122,6 +126,7 @@ main(int ac, char **av) const char *const *p; char *ep; int errors = 0; + int jid; int mib[4]; size_t miblen; int st, nprocs; @@ -142,6 +147,18 @@ main(int ac, char **av) if (**av == '-') { ++*av; switch (**av) { + case 'j': + ++*av; + if (**av == '\0') + ++av; + --ac; + jflag++; + jid = strtol(*av, &ep, 10); + if (!*av || *ep) + errx(1, "illegal jid: %s", *av); + if (jail_attach(jid) == -1) + err(1, "jail_attach(): %d", jid); + break; case 'u': ++*av; if (**av == '\0') @@ -206,7 +223,7 @@ main(int ac, char **av) } } - if (user == NULL && tty == NULL && cmd == NULL && ac == 0) + if (user == NULL && tty == NULL && cmd == NULL && !jflag && ac == 0) usage(); if (tty) { @@ -324,6 +341,8 @@ main(int ac, char **av) matched = 0; } } + if (jflag && thispid == getpid()) + matched = 0; if (matched == 0) continue; if (ac > 0) |