3 ms·
I suspect that, if you read those “custom versions of read(2) and write(2)”, you’ll discover that those APIs “leave something to be desired”. For example, let’
by Someone 7y ago
I suspect that, if you read those “custom versions of read(2) and write(2)”, you’ll discover that those APIs “leave something to be desired”.
For example, let’s say you want to write a 100 byte struct to file, and write returns 0 and sets errno to EINTR, or return 67 and keep errno as is.
Why would you write the code to handle those cases in every function that writes data? How would you fix all those entry points if you discover your handling is buggy, or that some commonly used file system is buggy, and you need to implement a workaround?
Similarly, if you read those 100 bytes, your call may return 67 and update the file position. You need code to recover from that. Why duplicate that throughout your code?