/* -*-c-*-
*
- * $Id: xwait.c,v 1.3 1998/11/21 22:30:27 mdw Exp $
+ * $Id: xwait.c,v 1.6 1998/12/11 09:50:07 mdw Exp $
*
* Wait until prodded by another X client
*
/*----- Revision history --------------------------------------------------*
*
* $Log: xwait.c,v $
+ * Revision 1.6 1998/12/11 09:50:07 mdw
+ * Minor modifications to work with mLib and mgLib.
+ *
+ * Revision 1.5 1998/11/30 22:36:53 mdw
+ * Tidy up tabbing in help texts very slightly.
+ *
+ * Revision 1.4 1998/11/21 22:41:19 mdw
+ * Reap children which die before I get my signal handler installed.
+ *
* Revision 1.3 1998/11/21 22:30:27 mdw
* Support GNU-style long options throughout, and introduce proper help
* text to all programs. Update manual pages to match.
#include <X11/Xlib.h>
#include <X11/Xutil.h>
-#include "mdwopt.h"
-#include "quis.h"
+#include <mLib/mdwopt.h>
+#include <mLib/quis.h>
+
#include "xwait.h"
/*----- Main code ---------------------------------------------------------*/
"-d, --display=DISPLAY Choose X display to connect to\n"
"-f, --force Run even if this property is waited for by another\n"
" process\n"
-"-a, --atom=ATOM Choose property name to listen for\n"
+"-a, --atom=ATOM\t Choose property name to listen for\n"
"-m, --msg=MSG Choose value of property to wait for\n",
stdout);
exit(0);
{
struct sigaction sa;
+ sigset_t ss, oss;
+
+ /* --- Set the handler up --- */
sa.sa_handler = sigchld;
sigemptyset(&sa.sa_mask);
sigaddset(&sa.sa_mask, SIGCHLD);
sa.sa_flags = 0;
sigaction(SIGCHLD, &sa, 0);
+
+ /* --- Now reap any which have been waiting around so far --- */
+
+ sigemptyset(&ss);
+ sigaddset(&ss, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &ss, &oss);
+ sigchld(SIGCHLD);
+ sigprocmask(SIG_SETMASK, &oss, 0);
}
/* --- Now wait for an event --- */