diff options
author | ed <ed@FreeBSD.org> | 2008-09-30 17:30:39 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2008-09-30 17:30:39 +0000 |
commit | a0cc7208a877d45b1c8c66817540a77154c36271 (patch) | |
tree | 668455da92df506249c2bb5349453c05edd4fbcb /bin/pkill/pkill.c | |
parent | 897af1f2383137e9de1003971e8fda083c37d0bb (diff) | |
download | FreeBSD-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/pkill.c')
-rw-r--r-- | bin/pkill/pkill.c | 18 |
1 files changed, 10 insertions, 8 deletions
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; |