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:
bms 2008-05-03 02:29:02 +00:00
parent c683ca0c36
commit b1c6637111
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));
}