3 ms·
you're being too negative, it's as if you don't understand "worse is better". >If you read /proc, you must "read" each file with one unbuffered kernel read to
by fsckboy 3y ago
you're being too negative, it's as if you don't understand "worse is better".
>If you read /proc, you must "read" each file with one unbuffered kernel read to be free of race conditions.
you make this sound like it's some arcane and tricky incantation; it's totally normal, like saying "to walk, put one foot in front of the other". It's unix file I/O 101, bufferless file operations are always atomic, it's a feature. There is absolutely no problem making atomic reads from files, it's a massive fucking feature.
The point is not that this is the best conceivable way to get this information, but that by making this information available this way by default, you can write and leverage all sorts of shell scripts while you are noodling at your keyboard. You don't very often need to turn your keyboard noodling into a 6-sigma 5-nines server, but if you know how to rip through this type of keyboard noodling, I'd trust you a lot more when it comes to uptime than all the people who show up at meetings ranting about 6-sigma and 5-nines while they cite Dave Cutler.
btw linux the /proc text file tree has already been supplanted by a binary "restatement" of the same and more data. I think this is more in keeping with the standard unix/solaris /proc approach, but it's not something I've had a need to look into much.
- Animats 3y agoSee the example in the original article. The article author does not know they have to do that, and wrote code which uses "fread".