From 4e1d114f4e4bba88e8a9728acc32ee097ee9091c Mon Sep 17 00:00:00 2001 From: Bill Kolokithas Date: Tue, 4 Feb 2014 22:28:01 +0200 Subject: [PATCH] check return value of fgets and exit main loop if EOF is received --- bar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bar.c b/bar.c index 6c244fb..bea1829 100644 --- a/bar.c +++ b/bar.c @@ -568,7 +568,9 @@ main (int argc, char **argv) else break; /* ...bail out */ } if (pollin[0].revents & POLLIN) { /* New input, process it */ - fgets (input, sizeof(input), stdin); + if (fgets (input, sizeof(input), stdin) == NULL) + break; /* EOF received */ + parse (input); redraw = 1; }