From 15da77e3d343e091c0ffdcb8dc20e638951d2d50 Mon Sep 17 00:00:00 2001
From: yamt <yamt@NetBSD.org>
Date: Wed, 5 Jun 2002 12:19:23 +0000
Subject: [PATCH] exit on EOF from stdin.

---
 sbin/fdisk/fdisk.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
index be86af38aa1a..5d7ec9d083e4 100644
--- a/sbin/fdisk/fdisk.c
+++ b/sbin/fdisk/fdisk.c
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdisk.c,v 1.52 2002/04/03 03:17:36 thorpej Exp $ */
+/*	$NetBSD: fdisk.c,v 1.53 2002/06/05 12:19:23 yamt Exp $ */
 
 /*
  * Mach Operating System
@@ -29,7 +29,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: fdisk.c,v 1.52 2002/04/03 03:17:36 thorpej Exp $");
+__RCSID("$NetBSD: fdisk.c,v 1.53 2002/06/05 12:19:23 yamt Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -827,7 +827,8 @@ editentries:
 
 		printf("Enter descriptions (max. 8 characters): ");
 		rewind(stdin);
-		fgets(desc, PARTNAMESIZE + 1, stdin);
+		if (!fgets(desc, PARTNAMESIZE + 1, stdin))
+			errx(1, "EOF");
 		fpurge(stdin);
 		p = strchr(desc, '\n');
 		if (p != NULL)
@@ -1367,6 +1368,8 @@ yesno(const char *str)
 	first = ch = getchar();
 	while (ch != '\n' && ch != EOF)
 		ch = getchar();
+	if (ch == EOF)
+		errx(1, "EOF");
 	return (first == 'y' || first == 'Y');
 }
 
@@ -1379,7 +1382,8 @@ decimal(const char *str, int *num)
 	for (;; printf("%s is not a valid decimal number.\n", lbuf)) {
 		printf("%s: [%d] ", str, *num);
 
-		fgets(lbuf, LBUF, stdin);
+		if (!fgets(lbuf, LBUF, stdin))
+			errx(1, "EOF");
 		lbuf[strlen(lbuf)-1] = '\0';
 		cp = lbuf;