libnative: Convert non-blocking fds to blocking when necessary

When doing a read or write on a file descriptor, if it returns EAGAIN or
EWOULDBLOCK, we need to turn off the O_NONBLOCK flag and try again. This
can happen because TTYs and FIFOs share the file descriptor flags with
other processes.

I'm a little uncomfortable with having to hard-code the values for
F_GETFL, F_SETFL, and O_NONBLOCK, but I don't know the process for
getting those into libc.