Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Of course, this is meaningless, as you can't actually do any common operation, except maybe Close*, on all of them.

You can write and read on anything on Unix that "is a file". You can't open or close all of them.

Annoyingly, files come in 2 flavors, and you are supposed to optimize your reads and writes differently.



You can call write() and read() on any file descriptor, but it won't necessarily do something meaningful. For example, calling them on a socket in listen mode won't do anything meaningful. And many special files don't implement at least one of read or write - for example, reading or writing to many of the special files in /proc/fs doesn't do anything.


You can try to read/write the same on Windows: ReadFile (and friends) take a HANDLE.

It won't make sense to try to read from all things you can get a HANDLE to on Windows either, but it's up to what created the HANDLE/object as to what operations are valid.

https://learn.microsoft.com/en-us/windows/win32/sysinfo/kern...




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: