X-Git-Url: https://git.distorted.org.uk/~mdw/xtoys/blobdiff_plain/c4efa11c1a060884e0d2f3c61a769d1e51396ae6..d72bdcdbbe512494f64102d18879a08163f231a3:/xwait.c diff --git a/xwait.c b/xwait.c index d18fa36..c74d2e2 100644 --- a/xwait.c +++ b/xwait.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: xwait.c,v 1.6 1998/12/11 09:50:07 mdw Exp $ + * $Id: xwait.c,v 1.7 1999/06/19 23:42:37 mdw Exp $ * * Wait until prodded by another X client * @@ -29,6 +29,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: xwait.c,v $ + * Revision 1.7 1999/06/19 23:42:37 mdw + * Improve signal handling. + * * Revision 1.6 1998/12/11 09:50:07 mdw * Minor modifications to work with mLib and mgLib. * @@ -53,6 +56,7 @@ /*----- Header files ------------------------------------------------------*/ +#include #include #include #include @@ -76,8 +80,10 @@ static void sigchld(int sig) { + int e = errno; while (waitpid(-1, 0, WNOHANG) > 0) ; + errno = e; } /* --- @main@ --- */ @@ -239,7 +245,10 @@ int main(int argc, char *argv[]) sa.sa_handler = sigchld; sigemptyset(&sa.sa_mask); sigaddset(&sa.sa_mask, SIGCHLD); - sa.sa_flags = 0; + sa.sa_flags = SA_NOCLDSTOP; +#ifdef SA_RESTART + sa.sa_flags |= SA_RESTART; +#endif sigaction(SIGCHLD, &sa, 0); /* --- Now reap any which have been waiting around so far --- */