Fix return value when read/write on the fd.