3 ms·
The simple POSIX write/read works nicely enough for IO – where simple includes the loop to check the return code and then errno for cases that should be retried
by jws 11y ago
The simple POSIX write/read works nicely enough for IO – where simple includes the loop to check the return code and then errno for cases that should be retried, ( EINTR, EAGAIN, EWOULDBLOCK, depending on what you are doing and your OS), adjust your arguments for how much data actually got sent or read, and then retry. Also be aware that depending on your file descriptor you might be making storms of tiny context switches, interrupts, and IOs.
Old Unix programmers handle that with about as much thought as breathing, but only because they were young unix programmers once.
Copying the bytes one more time isn't the worst thing that you will ever make a computer do. The stdio.h level is pretty nice from the standpoint of keeping your foot un-blown-off.