sajad torkamani

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

File descriptorDescription
0stdin
1stdout
2stderr

View file descriptors used by a process

Run

lsof -p <process-id>

If your process uses stdin, stdout, or stderr, you should see an entry with 0, 1, or 2 as the FD (file descriptor) value.

Tagged: Unix

Leave a comment

Your email address will not be published. Required fields are marked *