From: Paul Eggert Date: Fri, 10 Jun 2016 06:11:40 +0000 (-0700) Subject: Prefer getsockopt to getpeername on non-MS-Windows X-Git-Tag: emacs-26.0.90~1840^2~244^2~1 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=07b77b8ee02192a6d60c87002bb89a1eaee1aecc;p=emacs.git Prefer getsockopt to getpeername on non-MS-Windows * admin/CPP-DEFINES: Remove HAVE_GETPEERNAME. * configure.ac: Don’t check for getpeername. * src/process.c (wait_reading_process_output) [!WINDOWSNT]: Use getsockopt even if not GNU/Linux, as the platforms where getsockopt used to hang are no doubt long dead. --- diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index d9df152bff5..c7ec8ce6fed 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES @@ -156,7 +156,6 @@ HAVE_GETLOADAVG HAVE_GETOPT_H HAVE_GETOPT_LONG_ONLY HAVE_GETPAGESIZE -HAVE_GETPEERNAME HAVE_GETPT HAVE_GETPWENT HAVE_GETRLIMIT diff --git a/configure.ac b/configure.ac index a367582f2ab..069a7260e88 100644 --- a/configure.ac +++ b/configure.ac @@ -3848,7 +3848,7 @@ lrand48 random rint \ select getpagesize setlocale newlocale \ getrlimit setrlimit shutdown \ pthread_sigmask strsignal setitimer \ -sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \ +sendto recvfrom getsockname getifaddrs freeifaddrs \ gai_strerror sync \ getpwent endpwent getgrent endgrent \ cfmakeraw cfsetspeed copysign __executable_start log2) diff --git a/src/process.c b/src/process.c index 5e06ccccac8..4d287d8cc51 100644 --- a/src/process.c +++ b/src/process.c @@ -5492,15 +5492,16 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, p = XPROCESS (proc); -#ifdef GNU_LINUX - /* getsockopt(,,SO_ERROR,,) is said to hang on some systems. - So only use it on systems where it is known to work. */ +#ifndef WINDOWSNT { socklen_t xlen = sizeof (xerrno); if (getsockopt (channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen)) xerrno = errno; } #else + /* On MS-Windows, getsockopt clears the error for the + entire process, which may not be the right thing; see + w32.c. Use getpeername instead. */ { struct sockaddr pname; socklen_t pnamelen = sizeof (pname);