[PATCH:xhost] Drop pre-POSIX signal handling support in favor of sigaction()

Alan Coopersmith alan.coopersmith at oracle.com
Sat Feb 23 09:53:48 PST 2013


X_NOT_POSIX has never been defined by our autoconf scripts, only the
old Imake configuration, so this doesn't seem to have been needed in years.

First pass was done with 'unifdef -UX_NOT_POSIX', followed by
manual tweaking to adjust indent levels, etc.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---

Are there any platforms left that don't support the POSIX sigaction functions?
It looks like they'd have had to be building with CFLAGS="-DX_NOT_POSIX" if
there are, which is a horrible way for us to know upstream what they need.

 xhost.c |   40 ++++------------------------------------
 1 file changed, 4 insertions(+), 36 deletions(-)

diff --git a/xhost.c b/xhost.c
index f5633a1..9b7de42 100644
--- a/xhost.c
+++ b/xhost.c
@@ -73,9 +73,6 @@ X Window System is a trademark of The Open Group.
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
-#ifdef X_NOT_POSIX
-#include <setjmp.h>
-#endif
 #include <ctype.h>
 #include <X11/Xauth.h>
 #include <X11/Xmu/Error.h>
@@ -98,7 +95,7 @@ X Window System is a trademark of The Open Group.
 #include <limits.h>
 #undef _POSIX_C_SOURCE
 #else
-#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)
+#ifdef _POSIX_SOURCE
 #include <limits.h>
 #else
 #define _POSIX_SOURCE
@@ -637,9 +634,6 @@ change_host(Display *dpy, char *name, Bool add)
  * be found.
  */
 
-#ifdef X_NOT_POSIX
-jmp_buf env;
-#endif
 
 static const char *
 get_hostname(XHostAddress *ha)
@@ -653,9 +647,7 @@ get_hostname(XHostAddress *ha)
     char *kname;
     static char kname_out[255];
 #endif
-#ifndef X_NOT_POSIX
     struct sigaction sa;
-#endif
 
 #ifdef TCPCONN
 #if defined(IPv6) && defined(AF_INET6)
@@ -692,22 +684,13 @@ get_hostname(XHostAddress *ha)
 	   gethostbyaddr will continue after a signal, so we have to
 	   jump out of it. 
 	   */
-#ifndef X_NOT_POSIX
 	memset(&sa, 0, sizeof sa);
 	sa.sa_handler = nameserver_lost;
 	sa.sa_flags = 0;	/* don't restart syscalls */
 	sigaction(SIGALRM, &sa, NULL);
-#else
-	signal(SIGALRM, nameserver_lost);
-#endif
 	alarm(NAMESERVER_TIMEOUT);
-#ifdef X_NOT_POSIX
-	if (setjmp(env) == 0) 
-#endif
-	{ 
-	    getnameinfo((struct sockaddr *) &saddr, saddrlen, inetname,
-	      sizeof(inetname), NULL, 0, 0);
-	}
+	getnameinfo((struct sockaddr *) &saddr, saddrlen, inetname,
+		    sizeof(inetname), NULL, 0, 0);
 	alarm(0);
 	if (nameserver_timedout || inetname[0] == '\0')
 	    inet_ntop(((struct sockaddr *)&saddr)->sa_family, ha->address,
@@ -722,22 +705,12 @@ get_hostname(XHostAddress *ha)
 	   gethostbyaddr will continue after a signal, so we have to
 	   jump out of it. 
 	   */
-#ifndef X_NOT_POSIX
 	memset(&sa, 0, sizeof sa);
 	sa.sa_handler = nameserver_lost;
 	sa.sa_flags = 0;	/* don't restart syscalls */
 	sigaction(SIGALRM, &sa, NULL);
-#else
-	signal(SIGALRM, nameserver_lost);
-#endif
 	alarm(4);
-#ifdef X_NOT_POSIX
-	if (setjmp(env) == 0) {
-#endif
-	    hp = gethostbyaddr (ha->address, ha->length, AF_INET);
-#ifdef X_NOT_POSIX
-	}
-#endif
+	hp = gethostbyaddr (ha->address, ha->length, AF_INET);
 	alarm(0);
 	if (hp)
 	    return (hp->h_name);
@@ -823,11 +796,6 @@ static void
 nameserver_lost(int sig)
 {
     nameserver_timedout = 1;
-#ifdef X_NOT_POSIX
-    /* not needed with POSIX signals - stuck syscalls will not 
-       be restarted after signal delivery */
-    longjmp(env, -1);
-#endif
 }
 
 /*
-- 
1.7.9.2



More information about the xorg-devel mailing list