From 19250c1aed852e151bf66819e75f8d796018223b Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 23 Feb 2013 09:47:42 -0800 Subject: Drop pre-POSIX signal handling support in favor of sigaction() X_NOT_POSIX has never been defined by our autoconf scripts, only for a few platforms in , of which MinGW seems to be the most relevant today, and since that doesn't have alarm() it doesn't need this code either. First pass was done with 'unifdef -UX_NOT_POSIX', followed by manual tweaking to adjust indent levels, etc. Signed-off-by: Alan Coopersmith Reviewed-by: Jon TURNEY --- xhost.c | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/xhost.c b/xhost.c index 24eec97..a5edc08 100644 --- a/xhost.c +++ b/xhost.c @@ -73,9 +73,6 @@ X Window System is a trademark of The Open Group. #include #include #include -#ifdef X_NOT_POSIX -#include -#endif #include #include #include @@ -104,7 +101,7 @@ X Window System is a trademark of The Open Group. #include #undef _POSIX_C_SOURCE #else -#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE) +#ifdef _POSIX_SOURCE #include #else #define _POSIX_SOURCE @@ -643,9 +640,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) @@ -659,9 +653,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) @@ -698,22 +690,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, @@ -728,22 +711,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); @@ -829,11 +802,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 } /* -- cgit v1.2.3