Handle EBADF and EINTR correctly for close and shutdown
Return errors from opening sockets