summaryrefslogtreecommitdiffstats
path: root/monop/misc.c
diff options
context:
space:
mode:
authorahoka <ahoka@NetBSD.org>2011-12-01 07:05:52 +0000
committerahoka <ahoka@NetBSD.org>2011-12-01 07:05:52 +0000
commit43eaede84e20b51cd83e5e7b2c731b2ba749a30a (patch)
tree3a81d6702620122874b40944e2aa11d248852e0f /monop/misc.c
parent65dc63694f4b73fa9ab999ec34c932de770f8457 (diff)
downloadbsdgames-darwin-43eaede84e20b51cd83e5e7b2c731b2ba749a30a.tar.gz
bsdgames-darwin-43eaede84e20b51cd83e5e7b2c731b2ba749a30a.tar.zst
bsdgames-darwin-43eaede84e20b51cd83e5e7b2c731b2ba749a30a.zip
handle EOF in input
Diffstat (limited to 'monop/misc.c')
-rw-r--r--monop/misc.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/monop/misc.c b/monop/misc.c
index 3f881072..c69b90d0 100644
--- a/monop/misc.c
+++ b/monop/misc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: misc.c,v 1.21 2009/08/12 08:10:49 dholland Exp $ */
+/* $NetBSD: misc.c,v 1.22 2011/12/01 07:05:52 ahoka Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: misc.c,v 1.21 2009/08/12 08:10:49 dholland Exp $");
+__RCSID("$NetBSD: misc.c,v 1.22 2011/12/01 07:05:52 ahoka Exp $");
#endif
#endif /* not lint */
@@ -106,8 +106,9 @@ get_int(prompt)
for (;;) {
printf("%s", prompt);
fgets(buf, sizeof(buf), stdin);
+ /* if stdin is closed we cant really play anymore */
if (feof(stdin))
- return 0;
+ quit();
sp = strchr(buf, '\n');
if (sp)
*sp = '\0';
@@ -294,6 +295,11 @@ void
quit()
{
putchar('\n');
+
+ /* We dont even have a chance to input y/n if stdin is closed */
+ if (feof(stdin))
+ exit(0);
+
if (getyn("Do you all really want to quit? ") == 0)
exit(0);
}