Hi, Masao Uebayashi wrote on Wed, Jun 24, 2015 at 12:16:35PM +0900:
> ls(1) omits fts_close(3) after fts_open(3), resulting in an FD leak. > Found by Valgrind. As far as i can see, the code is correct, there doesn't seem to be a leak. The function traverse() is static and only called at the very end of ls_main(). The function ls_main() is only called at the very end of main(), file main.c. So your patch would close the file descriptor right before exit. Yours, Ingo > Index: bin/ls/ls.c > =================================================================== > RCS file: /cvs/src/bin/ls/ls.c,v > retrieving revision 1.40 > diff -u -p -r1.40 ls.c > --- bin/ls/ls.c 18 Apr 2015 18:28:36 -0000 1.40 > +++ bin/ls/ls.c 24 Jun 2015 03:10:47 -0000 > @@ -403,6 +403,8 @@ traverse(int argc, char *argv[], int opt > } > if (errno) > err(1, "fts_read"); > + > + fts_close(ftsp); > } > > /*
