5 ms·
+ "On UNIX, the adage goes, everything is a file." - not all the things on unix are abstracted as files (or 'byte streams' to be more accurate). however, i/o r
by barhun 10y ago
+ "On UNIX, the adage goes, everything is a file."
- not all the things on unix are abstracted as files (or 'byte streams' to be more accurate). however, i/o resources and some ipc facilities are defined so. an operating system provides many other abstractions in addition to these such as processes, threads, non-stream devices, concurrency and synchronization primitives, etc.; thus it's absolutely wrong to say that everything is a file on unix.
- darfs 10y agoCould this provide an example please? Only for those like me, who are wondering...^^
- RJIb8RBYxzAMX9u 10y ago"Everything is a file on UNIX" is as true as "Vulcan's cannot lie."
- na85 10y agoI assume Vulcans can lie?
- LeoPanthera 10y agoTechnically they cannot lie. But they can exaggerate. Or omit facts.
- sh_tinh_hair 10y agoGreat analogy.
- qubex 10y agoMost notably: network sockets do not have file-like semantics, mainly because they were introduced as a concept and implemented long after the system was designed. Plan9 is an effort to revise all system objects to be accessible with the same file-like fopen/fclose system calls.
- sh_tinh_hair 10y agoOnly one ipc primitive (fifo) can be used with man 2 read or write. Sysv ipc cannot, sockets (any domain) cannot (unless there is a kernel interface via /proc or another pseudo fs). What is meant by this saying (and the way it is has been used in my experience) is that everything in unix _looks_ like a file. That is usually meant in reference to the C API which has some r[ec]v|read|write|snd type namespace.
- deathanatos 10y agoYou can read(2) and write(2) to a socket, although it is more normal to recv and send on it. On Linux, you can also (and pretty much MUST) read(2) and write(2) to an eventfd; you can read(2) from a timerfd. That said, the semantics of the latter are considerably different from that of fifos or sockets.
- sh_tinh_hair 10y agoYou are right. I've long forgotten about read() and write() compat with sockets for very good reason. I don't lump an eventfd into the same IPC category as those mentioned in parent for the semantic(s) reason you mention and also for it's intended usage.