Linux File Descriptors
Ғылым және технология
In Linux, a file descriptor is a non-negative integer that identifies an opened file or other input/output resource such as a network socket or a pipe.
You are allowed to have up to 9 file descriptors open at a time.
However, bash shell reserves the first three file descriptors (0, 1, and 2).
0 STDIN Standard input
1 STDOUT Standard output
2 STDERR Standard error output
File descriptors are used to interact with these resources using various system calls such as read(), write(), and close().
By convention, the first three file descriptors (0, 1, and 2) are pre-defined and are reserved for standard input, standard output, and standard error streams respectively.
File descriptors greater than 2 are typically used to represent opened files or other resources. When a file or resource is opened, the operating system assigns a unique file descriptor to it and returns that file descriptor to the calling process.
File descriptors are a fundamental concept in Linux and are essential for many types of system programming tasks. Understanding how to use file descriptors is critical for developing efficient and robust applications on Linux.
Пікірлер: 6
Thanks super simple to understand
Great explanation, thank you!
@nikkiinit
Жыл бұрын
Glad it was helpful!. ❤️
Hay algún curso de esto en español?
Interesting, why would I use them rather than the file name, which seems much simpler.
@nikkiinit
Жыл бұрын
Hi, Vasco. You use file descriptors for data integrity. It is used a lot in linux especially if more than one person working on the same file.