From: Denis Vlasenko Date: Sun, 15 Oct 2006 18:38:01 +0000 (-0000) Subject: grep: -r didn't close files, producing "Too many open files" X-Git-Tag: 1_4_0~504 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf39216cc4e095a7ce9a4b33b778c903b916e18b;p=platform%2Fupstream%2Fbusybox.git grep: -r didn't close files, producing "Too many open files" --- diff --git a/findutils/grep.c b/findutils/grep.c index 12cad34..04dd2b0 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -301,6 +301,7 @@ static int file_action_grep(const char *filename, struct stat *statbuf, void* ma } cur_file = filename; *(int*)matched += grep_file(file); + fclose(file); return 1; } @@ -446,13 +447,13 @@ int grep_main(int argc, char **argv) } } matched += grep_file(file); + bb_fclose_nonstdin(file); grep_done: if (matched < 0) { /* we found a match but were told to be quiet, stop here and * return success */ break; } - bb_fclose_nonstdin(file); } /* destroy all the elments in the pattern list */