Jerry Chen Jerry Chen - 1 year ago 72
Linux Question

What is not file in Linux

When I first learned Linux, I was told almost everything in Linux is file. This morning, when I repeated it to my girlfriend. She asked what is not? I tried to find an example for half a day.

So my question is what is not file in Linux?

Answer Source

Almost. Almost everything in Posix is handled through a file descriptor. This means that the same functions used for file operations also apply for pipes, sockets, and hardware devices. This also means that if you use select (or one of its better alternatives), you can have one point in your program where you wait for all possible inputs.

With that said, some things in Posix, and in particular, in Linux, are definitely not files.

The most obvious ones are signals. They are handled asynchronously to the program's execution, and therefor cannot take on a file interface. For that purpose, pselect and one of its better alternatives were invented.

Things more subtly not files are thread synchronization constructs (mutexs, semaphores, etc.). Some attempt have been made to make those available as file descriptors as well (see signalfd and eventfd), but those hardly caught on. I believe that this is due, in large part, for them having a vastly different performance profiles than the ususal way of handling them.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download