summaryrefslogtreecommitdiff
path: root/xhost.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-02-23 09:47:42 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-02-28 18:11:38 -0800
commit19250c1aed852e151bf66819e75f8d796018223b (patch)
treeb56a5a70c99d67ef1ddb6338edf5bf9e5303046d /xhost.c
parent618eebf5aa99138f6ab3b8a96f93eb422f1a138e (diff)
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 <X11/Xosdefs.h>, 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 <alan.coopersmith@oracle.com> Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Diffstat (limited to 'xhost.c')
-rw-r--r--xhost.c40
1 files 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 <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>
@@ -104,7 +101,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
@@ -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
}
/*