summaryrefslogtreecommitdiffstats
path: root/bin/pkill
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2008-09-30 17:30:39 +0000
committered <ed@FreeBSD.org>2008-09-30 17:30:39 +0000
commita0cc7208a877d45b1c8c66817540a77154c36271 (patch)
tree668455da92df506249c2bb5349453c05edd4fbcb /bin/pkill
parent897af1f2383137e9de1003971e8fda083c37d0bb (diff)
downloadFreeBSD-src-a0cc7208a877d45b1c8c66817540a77154c36271.zip
FreeBSD-src-a0cc7208a877d45b1c8c66817540a77154c36271.tar.gz
Improve the `pkill -t' handling, which I changed in my previous commit.
In my previous commit I disabled pkill(1)'s automatic prepending of the "tty" string when `pkill -t' was being used. Re-enable it and stat() both possible device names when called. Requested by: jhb, rwatson (MFC) MFC after: 1 month
Diffstat (limited to 'bin/pkill')
-rw-r--r--bin/pkill/pkill.17
-rw-r--r--bin/pkill/pkill.c18
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;
OpenPOWER on IntegriCloud