Make socket functions EINTR safe