|
From: Nigel H. <nj...@ba...> - 2006-08-14 07:02:59
|
Behdad Esfahbod wrote: > On Mon, 2006-08-14 at 10:46 +1000, Nicholas Nethercote wrote: >> On Sun, 13 Aug 2006, Paul Pluzhnikov wrote: >> >>> Nigel Horne wrote: >>> >>>> Since file descriptors are being tracked, it would be useful to warn of >>>> closing files that aren't open, perhaps --warn-close-fds=yes >>> You don't need something as advanced as VG for this. >>> Simple "strace -etrace=close ./a.out 2>&1 | grep EBADF" will do. >>> >>> Note however, that it is somewhat common UNIX practice to >>> close FDs that aren't open, and you are likely to encounter >>> such code in various libraries (it's often easier to just >>> close FD again, rather than keep track of whether it's >>> currently open or not). >> Yes, many programs do something not much more sophisticated than this: >> >> for (i = 0; i < BIG_NUMBER; i++) >> close(i); >> >> Nick > > That's kind of a dumb case of it, still popular. A more sophisticated > and common use is to do something like this in daemons: > > close (0); > close (1); > close (2); No-one would force those programmers to use the --warn-close-fds=yes option. -Nigel |