3 ms·
gnulib has a decent set of safety wrappers around read(2)/write(2). safe_rw() http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/safe-read.c;h=3dde5
by pdkl95 10y ago
gnulib has a decent set of safety wrappers around read(2)/write(2).
safe_rw() http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/safe-read.c;h=3dde5b513471876d97dba86da5270bd3b2c801b3;hb=HEAD http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=li...
This handles a single read/write, handles EINTER, and returns the amount that was successfully read/written.
full_rw() http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/full-write.c;h=08248ad5baf86117ab90b648b4d2ce855a86a011;hb=HEAD http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=li...
A wrapper around safe_rw() that handles advancing the pointer through the buffer, calling safe_rw() until the requested COUNT bytes have been sent/received.
--
In most cases, I recommend avoiding all of this and using the existing fopen/fread/fwrite/etc buffered I/O interface.