summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-10-22 23:59:41 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-10-22 23:59:41 +0000
commit2d3dbba519de058144ca2c9426a4a8313cd25fc8 (patch)
tree52a5726a02cf150b3b7da4bc1d9a54ad86356aa7
parent4cf4e50d3f2514c7715234cde554811d1510d49b (diff)
Use clearerr(3) to clear EOF on stdin when aborting a command due to ^D.
Fixes a bug exposed by the last revision (we got away with before it due to the rewind(3) calls).
-rw-r--r--sbin/disklabel/editor.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index 3ede3b2a66b..3812431d39f 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.73 2000/08/13 22:07:14 millert Exp $ */
+/* $OpenBSD: editor.c,v 1.74 2000/10/22 23:59:40 millert Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -28,7 +28,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: editor.c,v 1.73 2000/08/13 22:07:14 millert Exp $";
+static char rcsid[] = "$OpenBSD: editor.c,v 1.74 2000/10/22 23:59:40 millert Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -1045,6 +1045,7 @@ getstring(prompt, helpstring, oval)
if (fgets(buf, sizeof(buf), stdin) == NULL) {
buf[0] = '\0';
if (feof(stdin)) {
+ clearerr(stdin);
putchar('\n');
return(NULL);
}
@@ -1093,6 +1094,7 @@ getuint(lp, partno, prompt, helpstring, oval, maxval, offset, flags)
if (fgets(buf, sizeof(buf), stdin) == NULL) {
buf[0] = '\0';
if (feof(stdin)) {
+ clearerr(stdin);
putchar('\n');
return(UINT_MAX - 1);
}