From 1fe0ab595c45c784514bbda8746beb680d535889 Mon Sep 17 00:00:00 2001 From: Moritz Grimm Date: Thu, 24 Mar 2016 17:50:31 +0100 Subject: [PATCH] Improve fgets() error handling --- src/playlist.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/playlist.c b/src/playlist.c index 1e78614..7e26d42 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -126,10 +126,12 @@ _playlist_run_program(struct playlist *pl) return (NULL); } - fgets(buf, (int)sizeof(buf), filep); - if (ferror(filep)) { - log_error("%s: output read error: %s", pl->filename, - strerror(ferror(filep))); + if (NULL == fgets(buf, (int)sizeof(buf), filep)) { + if (ferror(filep)) + log_error("%s: output read error: %s", pl->filename, + strerror(ferror(filep))); + else + log_error("%s: output read error: EOF", pl->filename); pclose(filep); return (NULL); }