diff options
Diffstat (limited to 'bin')
-rw-r--r-- | bin/pkill/pkill.1 | 7 | ||||
-rw-r--r-- | bin/pkill/pkill.c | 18 |
2 files changed, 14 insertions, 11 deletions
diff --git a/bin/pkill/pkill.1 b/bin/pkill/pkill.1 index 22b67bf..725f27e 100644 --- a/bin/pkill/pkill.1 +++ b/bin/pkill/pkill.1 @@ -179,9 +179,10 @@ command. Restrict matches to processes associated with a terminal in the comma-separated list .Ar tty . -The -.Pa /dev/ -prefix of the terminal names must be omitted. +Terminal names may be of the form +.Pa tty Ns Ar xx +or the shortened form +.Ar xx . A single dash .Pq Ql - matches processes not associated with a terminal. diff --git a/bin/pkill/pkill.c b/bin/pkill/pkill.c index 649e7b7..da8fbcd 100644 --- a/bin/pkill/pkill.c +++ b/bin/pkill/pkill.c @@ -675,16 +675,18 @@ makelist(struct listhead *head, enum listtype type, char *src) } snprintf(buf, sizeof(buf), _PATH_DEV "%s", cp); + if (stat(buf, &st) != -1) + goto foundtty; - if (stat(buf, &st) == -1) { - if (errno == ENOENT) { - errx(STATUS_BADUSAGE, - "No such tty: `%s'", sp); - } - err(STATUS_ERROR, "Cannot access `%s'", sp); - } + snprintf(buf, sizeof(buf), _PATH_DEV "tty%s", cp); + if (stat(buf, &st) != -1) + goto foundtty; + + if (errno == ENOENT) + errx(STATUS_BADUSAGE, "No such tty: `%s'", sp); + err(STATUS_ERROR, "Cannot access `%s'", sp); - if ((st.st_mode & S_IFCHR) == 0) +foundtty: if ((st.st_mode & S_IFCHR) == 0) errx(STATUS_BADUSAGE, "Not a tty: `%s'", sp); li->li_number = st.st_rdev; |