writeall makes successive write calls to write an entire buffer to the output file descriptor. It returns the number of bytes written, or -1 on the first error.