Switching is_socket() to use getsockopt() instead of relying on fstat() to fail on non-file (e.g. socket) descriptors