Handle ptyfs ptys. Should probably pull up to 5.
This commit is contained in:
parent
8167178188
commit
b90f233b82
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: pkill.1,v 1.16 2008/04/30 13:11:01 martin Exp $
|
||||
.\" $NetBSD: pkill.1,v 1.17 2009/02/28 18:16:10 christos Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
|
@ -27,7 +27,7 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd February 25, 2006
|
||||
.Dd February 28, 2009
|
||||
.Dt PKILL 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -120,10 +120,19 @@ command.
|
|||
Restrict matches to processes associated with a terminal in the
|
||||
comma-separated list
|
||||
.Ar tty .
|
||||
Terminal names may be of the form
|
||||
.Sq ttyxx
|
||||
or the shortened form
|
||||
.Sq xx .
|
||||
Terminal names may be specified as a fully qualified path, in the form
|
||||
.Sq ttyXX ,
|
||||
or
|
||||
.Sq pts/N ,
|
||||
(where
|
||||
.Ar XX
|
||||
is any pair of letters, and
|
||||
.Ar N
|
||||
is a number),
|
||||
or the shortened forms
|
||||
.Sq XX
|
||||
or
|
||||
.Sq N .
|
||||
A single dash
|
||||
.Pq Sq -
|
||||
matches processes not associated with a terminal.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pkill.c,v 1.23 2008/04/28 20:24:14 martin Exp $ */
|
||||
/* $NetBSD: pkill.c,v 1.24 2009/02/28 18:16:11 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: pkill.c,v 1.23 2008/04/28 20:24:14 martin Exp $");
|
||||
__RCSID("$NetBSD: pkill.c,v 1.24 2009/02/28 18:16:11 christos Exp $");
|
||||
#endif /* !lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -503,7 +503,7 @@ makelist(struct listhead *head, enum listtype type, char *src)
|
|||
empty = 0;
|
||||
|
||||
li->li_number = (uid_t)strtol(sp, &ep, 0);
|
||||
if (*ep == '\0') {
|
||||
if (*ep == '\0' && type != LT_TTY) {
|
||||
switch (type) {
|
||||
case LT_PGRP:
|
||||
if (li->li_number == 0)
|
||||
|
@ -513,9 +513,6 @@ makelist(struct listhead *head, enum listtype type, char *src)
|
|||
if (li->li_number == 0)
|
||||
li->li_number = getsid(mypid);
|
||||
break;
|
||||
case LT_TTY:
|
||||
usage();
|
||||
/*NOTREACHED*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -536,29 +533,34 @@ makelist(struct listhead *head, enum listtype type, char *src)
|
|||
li->li_number = gr->gr_gid;
|
||||
break;
|
||||
case LT_TTY:
|
||||
if (strcmp(sp, "-") == 0) {
|
||||
p = sp;
|
||||
if (*sp == '/')
|
||||
prefix = "";
|
||||
else if (strcmp(sp, "-") == 0) {
|
||||
li->li_number = -1;
|
||||
break;
|
||||
} else if (strcmp(sp, "co") == 0)
|
||||
p = "console";
|
||||
else if (strncmp(sp, "tty", 3) == 0)
|
||||
p = sp;
|
||||
else {
|
||||
p = sp;
|
||||
/* all set */;
|
||||
else if (strncmp(sp, "pts/", 4) == 0)
|
||||
/* all set */;
|
||||
else if (*ep != '\0' || (strlen(sp) == 2 && *sp == '0'))
|
||||
prefix = _PATH_TTY;
|
||||
}
|
||||
else
|
||||
prefix = _PATH_DEV_PTS;
|
||||
|
||||
(void)snprintf(buf, sizeof(buf), "%s%s", prefix, p);
|
||||
|
||||
if (stat(buf, &st) == -1) {
|
||||
if (errno == ENOENT)
|
||||
errx(STATUS_BADUSAGE,
|
||||
"No such tty: `%s'", sp);
|
||||
err(STATUS_ERROR, "Cannot access `%s'", sp);
|
||||
"No such tty: `%s'", buf);
|
||||
err(STATUS_ERROR, "Cannot access `%s'", buf);
|
||||
}
|
||||
|
||||
if ((st.st_mode & S_IFCHR) == 0)
|
||||
errx(STATUS_BADUSAGE, "Not a tty: `%s'", sp);
|
||||
errx(STATUS_BADUSAGE, "Not a tty: `%s'", buf);
|
||||
|
||||
li->li_number = st.st_rdev;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue