How To Filet A Fish

Many people enjoy fishing, whether it is for recreational purposes or for a professional reason, the sport can be relaxing and provide fishermen with a tasty meal at the end of the day. If you have…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




What is a file descriptor?

Have you ever wondered when someone asks about the file descriptor limits on an operating system? All of a sudden, you think of what a file descriptor is and how can i get more information? This brief summary below will introduce you to file descriptor with an example.

In lay man terms, File Descriptor is just a number that uniquely identifies an open file in the operating system. Surprisingly, every thing is linux is treated as a file including I/O resources, files, directories, sockets etc. For instance, whenever a file is opened, the operating system creates an entry to represent this file and stores that information. Each entry is represented by an integer value and this entry is termed as file descriptor. These numbers serve as an handle to the underlying machine-specific structure representing an open file, an open socket, or another source or sink of bytes.

When we think of a file descriptor, we always think that they will be used for files. But, that is not true from operating system perspective. Logically, the operations performed on other types of resources such as Sockets are similar to the one that are being performed on a file. For instance, read(), write() and close(). Hence, everything is called a file descriptor to eliminate confusion.

Let’s understand this with an example. Run the below program which will print ProcessId and File Descriptor Number.

Once you have both the values, open terminal and run the below command.

Verify for the processId above, you should see an entry as below.

The number “23” in the above result represents the file descriptor, “w” stands for write access. The same concept applies for any resource that we are using on the operating system like sockets, IO streams etc.

On a operating system, there are certain limits imposed on the number of file descriptors that can be opened. To view the file descriptor limits, please use the below command.

Thanks for your time. Please let me know your comments.

Add a comment

Related posts:

Garage Door Opener Resolved Our Mystery

It was summer at its peak. Let alone the summer of Arizona with sultry heatwave and skin parching sun. In such a season, we were posted in a US airfield in Phoenix Arizona. I am an aeronautical…

Vamos incluir os conflitos nos nossos planos!

Estar em um relacionamento significa que vamos vivenciar conflitos mais cedo ou mais tarde. Ao invés de negar, evitar ou tentar gerenciar os conflitos depois que eles aparecem, tensões podem ser…

The Grind Will Never End

I just finished my web development intensive program and now it is time to find a job. After 6 months of signing away my social life and on a continuous grind to absorb as much software development…