To create a daemon I have read somewhere that in order to close all the open file descriptors we can use the following code:-
for (fd = 0; fd < _NFILE; fd++)
close(fd); /* close all file descriptors */
I have to define _NFILE as
#define _NFILE 3
or is it already defined in some include files?
I tried to grep it in the /usr/include directory but could not find anything.
_NFILEonly applies to original Unix. The portable way to do this issysconf(_SC_OPEN_MAX)(POSIX).