Relinquish exclusive TTY access when tip(1) or cu(1) exit.

Previously they would have left TIOCEXCL enabled, requiring
either a reboot or use of tip/cu as the root user.

Observed when running QEMU with character devices redirected to pty instances.

MFC after:	2 weeks
This commit is contained in:
Bruce M Simpson 2008-05-03 02:29:02 +00:00
parent 03bc210eb9
commit a0ad4c4d37
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=178736
4 changed files with 12 additions and 0 deletions

View file

@ -666,6 +666,7 @@ tipabort(char *msg)
daemon_uid();
(void)uu_unlock(uucplock);
unraw();
unexcl();
exit(0);
}

View file

@ -325,6 +325,15 @@ unraw(void)
tcsetattr(0, TCSADRAIN, &defterm);
}
/*
* give up exclusive tty access
*/
void
unexcl()
{
ioctl(FD, TIOCNXCL, 0);
}
static jmp_buf promptbuf;
/*

View file

@ -341,6 +341,7 @@ void timeout(int);
void tipabort(char *);
void tipout(void);
void user_uid(void);
void unexcl(void);
void unraw(void);
void v3451_abort(void);
void v3451_disconnect(void);

View file

@ -126,5 +126,6 @@ uu_unlock(char *ttyname)
char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN];
(void)snprintf(tbuf, sizeof tbuf, _PATH_LOCKDIRNAME, ttyname);
unexcl();
return(unlink(tbuf));
}