diff mbox series

[3/4] dismod: handle EOF in user interaction

Message ID 20230531013224.1135775-3-yamato@redhat.com (mailing list archive)
State Accepted
Commit d1a9cddfd2b0
Delegated to: Petr Lautrbach
Headers show
Series [1/4] dismod: add --help option | expand

Commit Message

Masatake YAMATO May 31, 2023, 1:32 a.m. UTC
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
 checkpolicy/test/dismod.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/checkpolicy/test/dismod.c b/checkpolicy/test/dismod.c
index f1b879b0..3b81b1ce 100644
--- a/checkpolicy/test/dismod.c
+++ b/checkpolicy/test/dismod.c
@@ -921,6 +921,8 @@  int main(int argc, char **argv)
 	for (;;) {
 		printf("\nCommand (\'m\' for menu):  ");
 		if (fgets(ans, sizeof(ans), stdin) == NULL) {
+			if (feof(stdin))
+				break;
 			fprintf(stderr, "fgets failed at line %d: %s\n", __LINE__,
 					strerror(errno));
 			continue;