Improve signal handling. Fix options parsing to POSIX order only.
authormdw <mdw>
Sat, 19 Jun 1999 23:42:55 +0000 (23:42 +0000)
committermdw <mdw>
Sat, 19 Jun 1999 23:42:55 +0000 (23:42 +0000)
xcatch.c

index fd0e0d6..4f99d19 100644 (file)
--- a/xcatch.c
+++ b/xcatch.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: xcatch.c,v 1.7 1999/05/21 22:09:19 mdw Exp $
+ * $Id: xcatch.c,v 1.8 1999/06/19 23:42:55 mdw Exp $
  *
  * Catch input and trap it in an X window
  *
@@ -29,6 +29,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: xcatch.c,v $
+ * Revision 1.8  1999/06/19 23:42:55  mdw
+ * Improve signal handling.  Fix options parsing to POSIX order only.
+ *
  * Revision 1.7  1999/05/21 22:09:19  mdw
  * Take advantage of new dynamic string macros.
  *
@@ -234,6 +237,7 @@ static void reap(int sig)
 {
   pid_t k;
   int s;
+  int e = errno;
 
   for (;;) {
     k = waitpid(-1, &s, WNOHANG);
@@ -246,6 +250,7 @@ static void reap(int sig)
        status = 127;
     }
   }
+  errno = e;
 }
 
 /* --- Main program --- */
@@ -277,7 +282,7 @@ int main(int argc, char *argv[])
       { "font",                OPTF_ARGREQ,    0,      'F' },
       { 0,             0,              0,      0 }
     };
-    int i = mdwopt(argc, argv, "huvf:F:", opt, 0, 0, 0);
+    int i = mdwopt(argc, argv, "+huvf:F:", opt, 0, 0, 0);
 
     if (i < 0)
       break;
@@ -342,7 +347,10 @@ int main(int argc, char *argv[])
 
       sa.sa_handler = reap;
       sigemptyset(&sa.sa_mask);
-      sa.sa_flags = 0;
+      sa.sa_flags = SA_NOCLDSTOP;
+#ifdef SA_RESTART
+      sa.sa_flags |= SA_RESTART;
+#endif
       sigaction(SIGCHLD, &sa, 0);
 
       /* --- Start a child program --- */