What is a file descriptor?
9 April 2023 (Updated 9 April 2023)
In a nutshell
In Unix-like operating systems, a file descriptor is an integer that uniquely identifies an open file or stream (e.g., socket). It’s generated when a file is created or opened and is used by the calling process to refer to the file in subsequent calls.
Reserved file descriptors
View file descriptors used by a process
lsof -p <process-id>
If your process uses stdin, stdout, or stderr, you should see an entry with
2 as the
FD (file descriptor) value.