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
This commit is contained in:
parent
897af1f238
commit
a0cc7208a8
@ -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.
|
||||
|
@ -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 ((st.st_mode & S_IFCHR) == 0)
|
||||
if (errno == ENOENT)
|
||||
errx(STATUS_BADUSAGE, "No such tty: `%s'", sp);
|
||||
err(STATUS_ERROR, "Cannot access `%s'", sp);
|
||||
|
||||
foundtty: if ((st.st_mode & S_IFCHR) == 0)
|
||||
errx(STATUS_BADUSAGE, "Not a tty: `%s'", sp);
|
||||
|
||||
li->li_number = st.st_rdev;
|
||||
|
Loading…
Reference in New Issue
Block a user