Skip to content

Commit 687dd75

Browse files
author
Junio C Hamano
committed
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 <junkio@cox.net>
1 parent da93d12 commit 687dd75

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pack-objects.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -915,9 +915,10 @@ int main(int argc, char **argv)
915915
break;
916916
if (!ferror(stdin))
917917
die("fgets returned NULL, not EOF, not error!");
918-
if (errno == EINTR)
919-
continue;
920-
die("fgets: %s", strerror(errno));
918+
if (errno != EINTR)
919+
die("fgets: %s", strerror(errno));
920+
clearerr(stdin);
921+
continue;
921922
}
922923

923924
if (progress_update) {

0 commit comments

Comments
 (0)