More points regarding File Descriptor
:
File Descriptors
(FD) are non-negative integers(0, 1, 2, ...)
that are associated with files that are opened.0, 1, 2
are standard FD's that corresponds toSTDIN_FILENO
,STDOUT_FILENO
andSTDERR_FILENO
(defined inunistd.h
) opened by default on behalf of shell when the program starts.FD's are allocated in the sequential order, meaning the lowest possible unallocated integer value.
FD's for a particular process can be seen in
/proc/$pid/fd
(on Unix based systems).