diff options
author | phk <phk@FreeBSD.org> | 2001-05-24 09:27:02 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2001-05-24 09:27:02 +0000 |
commit | 32050df42383ffccbc742dcc660c489d13a922a4 (patch) | |
tree | b6a1cf7b68fdc11d76ef4e4e9bcceb4517600e4a /usr.bin/tip | |
parent | f77345ea800c2b51c9688ef79af6b5826eb2712e (diff) | |
download | FreeBSD-src-32050df42383ffccbc742dcc660c489d13a922a4.zip FreeBSD-src-32050df42383ffccbc742dcc660c489d13a922a4.tar.gz |
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
Diffstat (limited to 'usr.bin/tip')
-rw-r--r-- | usr.bin/tip/tip/tip.c | 12 | ||||
-rw-r--r-- | usr.bin/tip/tip/tipout.c | 3 |
2 files changed, 14 insertions, 1 deletions
diff --git a/usr.bin/tip/tip/tip.c b/usr.bin/tip/tip/tip.c index 2b11d0b..1f910e5 100644 --- a/usr.bin/tip/tip/tip.c +++ b/usr.bin/tip/tip/tip.c @@ -81,6 +81,7 @@ int disc = OTTYDISC; /* tip normally runs this way */ void intprompt(); void timeout(); +void killchild(); void cleanup(); void tipdone(); char *sname(); @@ -286,6 +287,15 @@ usage() } 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, diff --git a/usr.bin/tip/tip/tipout.c b/usr.bin/tip/tip/tipout.c index de1fe6a..67932f6 100644 --- a/usr.bin/tip/tip/tipout.c +++ b/usr.bin/tip/tip/tipout.c @@ -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); |