summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-03-27 20:47:15 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-03-27 20:47:15 +0000
commitb75edbd87d4a4162eb776a72ffdb47d8026910ec (patch)
treedf839ed0bcc85c8d67f0b917c92de37901c8d8c3 /usr.bin
parent026aeeb099fb1518662ec05ca51737db5d9980ad (diff)
Fix write() loop in ttflush(). Pointed out by vincent@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/ttyio.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/mg/ttyio.c b/usr.bin/mg/ttyio.c
index c5e1889bf99..996c23d8895 100644
--- a/usr.bin/mg/ttyio.c
+++ b/usr.bin/mg/ttyio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ttyio.c,v 1.19 2002/03/27 17:42:37 millert Exp $ */
+/* $OpenBSD: ttyio.c,v 1.20 2002/03/27 20:47:14 millert Exp $ */
/*
* POSIX terminal I/O.
@@ -137,17 +137,17 @@ void
ttflush()
{
ssize_t written;
+ char *buf = obuf;
if (nobuf == 0)
return;
- while ((written = write(fileno(stdout), obuf, nobuf)) != nobuf) {
+ while ((written = write(fileno(stdout), buf, nobuf)) != nobuf) {
if (written == -1)
panic("ttflush write failed");
- else
- nobuf -= written;
+ buf += written;
+ nobuf -= written;
}
- nobuf = 0;
}
/*