safe_fgets() - even more anal fgets()
authorJunio C Hamano <junkio@cox.net>
Tue, 4 Apr 2006 06:41:09 +0000 (23:41 -0700)
committerJunio C Hamano <junkio@cox.net>
Tue, 4 Apr 2006 06:42:25 +0000 (23:42 -0700)
This is from Linus -- the previous round forgot to clear error
after EINTR case.

Signed-off-by: Junio C Hamano <junkio@cox.net>
pack-objects.c
index 084c2006a987c79dfbd2f70c616d46eac23ed50d..7d6247791d9374986c6fb85159433ecd91b9ccec 100644 (file)
@@ -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) {