*** ./client.c.ORIG Wed Jan 19 13:51:56 2011 --- ./client.c Wed Jan 19 14:00:47 2011 *************** *** 9,14 **** --- 9,17 ---- #include #include #include + #ifdef _AIX + #include + #endif #include "list.h" #include "wind.h" *** ./root.c.ORIG Wed Jan 19 14:01:08 2011 --- ./root.c Wed Jan 19 14:01:47 2011 *************** *** 5,10 **** --- 5,13 ---- #include #include #include + #ifdef _AIX + #include + #endif #include "wind.h" *** ./main.c.ORIG Sat Aug 16 00:31:31 2014 --- ./main.c Wed Aug 20 16:16:48 2014 *************** *** 39,44 **** --- 39,48 ---- #include "deleven.xbm" #include "delodd.xbm" + #ifdef _AIX + #include "pselect.c" + #endif + static int errhandler(Display *, XErrorEvent *); static void onsignal(int); static int waitevent(void); *************** *** 94,100 **** static XContext listeners; ! static sigset_t sigmask; /* * Print formatted error message --- 98,104 ---- static XContext listeners; ! static sigset_t MYsigmask; /* * Print formatted error message *************** *** 163,169 **** FD_SET(conn, &rfds); nfds = MAX(conn + 1, nfds); ! if (pselect(nfds, &rfds, NULL, NULL, NULL, &sigmask) == -1) { errorf("pselect: %s", strerror(errno)); exitstatus = 1; return -1; --- 167,173 ---- FD_SET(conn, &rfds); nfds = MAX(conn + 1, nfds); ! if (pselect(nfds, &rfds, NULL, NULL, NULL, &MYsigmask) == -1) { errorf("pselect: %s", strerror(errno)); exitstatus = 1; return -1; *************** *** 321,327 **** listeners = XUniqueContext(); sigset_t sigsafemask; ! sigprocmask(SIG_SETMASK, NULL, &sigmask); sigprocmask(SIG_SETMASK, NULL, &sigsafemask); struct sigaction sa; --- 325,331 ---- listeners = XUniqueContext(); sigset_t sigsafemask; ! sigprocmask(SIG_SETMASK, NULL, &MYsigmask); sigprocmask(SIG_SETMASK, NULL, &sigsafemask); struct sigaction sa; *** ./pselect.c.ORIG Wed Aug 20 16:16:10 2014 --- ./pselect.c Wed Aug 20 16:17:02 2014 *************** *** 0 **** --- 1,29 ---- + /* + * This is *not* a complete implementation of the Posix.1g pselect() + * function. For atomicity this must be implemented within the kernel, + * with the sigprocmask/select/sigprocmask performed as a single atomic + * operation. + * This is just a quick hack to allow simple programs using it to compile. + * Using such programs with this hack will probably lead to race conditions. + */ + + int + pselect(int nfds, fd_set *rset, fd_set *wset, fd_set *xset, + const struct timespec *ts, const sigset_t *sigmask) + { + int n; + struct timeval tv; + sigset_t savemask; + + if (ts != NULL) { + tv.tv_sec = ts->tv_sec; + tv.tv_usec = ts->tv_nsec / 1000; /* nanosec -> microsec */ + } + + sigprocmask(SIG_SETMASK, sigmask, &savemask); /* caller's mask */ + n = select(nfds, rset, wset, xset, (ts == NULL) ? NULL : &tv); + sigprocmask(SIG_SETMASK, &savemask, NULL); /* restore mask */ + + return(n); + } + /* end pselect */