If the user exists abruptly, tip's "tipout" child can hang around

forever. Since the lock file doesn't get cleaned up, this prevents
other users from accessing the target device.

(phk adds: Man, this has been bugging me for YEARS!)

PR:		12528
Submitted by:	Craig Leres leres@ee.lbl.gov
MFC after:	1 week
This commit is contained in:
Poul-Henning Kamp 2001-05-24 09:27:02 +00:00
parent ca517ad854
commit 62f9fae610
2 changed files with 14 additions and 1 deletions

View File

@ -81,6 +81,7 @@ int disc = OTTYDISC; /* tip normally runs this way */
void intprompt();
void timeout();
void killchild();
void cleanup();
void tipdone();
char *sname();
@ -285,6 +286,15 @@ usage()
exit(1);
}
void
killchild()
{
if (pid != 0) {
kill(pid, SIGTERM);
pid = 0;
}
}
void
cleanup()
{
@ -427,6 +437,8 @@ tipin()
int i;
char gch, bol = 1;
atexit(killchild);
/*
* Kinda klugey here...
* check for scripting being turned on from the .tiprc file,

View File

@ -160,7 +160,8 @@ tipout()
omask = sigblock(ALLSIGS);
for (cp = buf; cp < buf + cnt; cp++)
*cp &= 0177;
write(1, buf, cnt);
if (write(1, buf, cnt) < 0)
exit(1);
if (boolean(value(SCRIPT)) && fscript != NULL) {
if (!boolean(value(BEAUTIFY))) {
fwrite(buf, 1, cnt, fscript);