Make sure os.read/write() succeeds

...in the face of EINTR, and short writes (for write)

Signed-off-by: Chris Lalancette <clalancette@gmail.com>