From 687dd75c95f9212244b6cf4fe60b40db44de01ba Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 3 Apr 2006 23:41:09 -0700 Subject: [PATCH] safe_fgets() - even more anal fgets() This is from Linus -- the previous round forgot to clear error after EINTR case. Signed-off-by: Junio C Hamano --- pack-objects.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pack-objects.c b/pack-objects.c index 084c2006a..7d6247791 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -915,9 +915,10 @@ int main(int argc, char **argv) break; if (!ferror(stdin)) die("fgets returned NULL, not EOF, not error!"); - if (errno == EINTR) - continue; - die("fgets: %s", strerror(errno)); + if (errno != EINTR) + die("fgets: %s", strerror(errno)); + clearerr(stdin); + continue; } if (progress_update) { -- 2.30.2