Invoke revoke(2) on the slave pty in the pts(4) case (new_openpty()) to
kick off any other users on the device line before using it since openpty(3) is documented to do this. Note that grantpt(3) does not call revoke(2), it only adjusts permissions and ownership. MFC after: 3 days
This commit is contained in:
parent
b72597c775
commit
03594bb79f
@ -55,6 +55,7 @@ static int
|
||||
new_openpty(int *amaster, int *aslave, char *name, struct termios *termp,
|
||||
struct winsize *winp)
|
||||
{
|
||||
const char *slavename;
|
||||
int master, slave;
|
||||
|
||||
master = posix_openpt(O_RDWR);
|
||||
@ -66,7 +67,18 @@ new_openpty(int *amaster, int *aslave, char *name, struct termios *termp,
|
||||
return (-1);
|
||||
}
|
||||
|
||||
slave = open(ptsname(master), O_RDWR);
|
||||
slavename = ptsname(master);
|
||||
if (slavename == NULL) {
|
||||
close(master);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (revoke(slavename) == -1) {
|
||||
close(master);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
slave = open(slavename, O_RDWR);
|
||||
if (slave == -1) {
|
||||
close(master);
|
||||
return (-1);
|
||||
|
Loading…
Reference in New Issue
Block a user