On Sat, Dec 25, 2010 at 06:48:03PM +0100, David Kuehling wrote: > >>>>> "Alan" == Alan Post <[email protected]> writes: > > The value 1024 in the for loop closing all of the >=3 file > > descriptors should be determined through calling getrlimit with the > > RLIMIT_NOFILE parameter. And if you're being extra careful, take the > > min of 3 and the value getrlimit returns for you initial condition on > > that loop, to prevent integer overflow while looping. ;-) > > Didn't I say it's ugly :) This is what happens when programming via > trial&error :) > > Hopefully there are less problems with the 3-line version I just posted. >
The only suggestion I can make for that one is stylistic, in that I most often see code that *doesn't* use this idiom. However, unistd.h defines STDOUT_FILENO, which you could use rather than 1. I actually don't encounter that in the wild, much like I never really see EXIT_SUCCESS from stdlib.h. I personally find it easier to remember the numbers of the standard file descriptors than I do the define names. I'm clearly not the only one. :-) -Alan -- .i ko djuno fi le do sevzi _______________________________________________ Qi Hardware Discussion List Mail to list (members only): [email protected] Subscribe or Unsubscribe: http://lists.en.qi-hardware.com/mailman/listinfo/discussion

