*** empty log message ***
authorroot <root>
Wed, 30 Nov 2005 21:05:39 +0000 (21:05 +0000)
committerroot <root>
Wed, 30 Nov 2005 21:05:39 +0000 (21:05 +0000)
src/init.C
src/main.C
src/rxvt.h

index 728d14ff81d3bcdde31daf3d1473a42f6cbc900a..e0da5eea711ef822616e25c7d80e89c94746cff5 100644 (file)
@@ -218,9 +218,6 @@ const char *const xa_names[] =
 bool
 rxvt_term::init_vars ()
 {
-  sw_term.start (SIGTERM);
-  sw_int.start  (SIGINT);
-
   pix_colors_focused = new rxvt_color [TOTAL_COLORS];
 #ifdef OFF_FOCUS_FADING
   pix_colors_unfocused = new rxvt_color [TOTAL_COLORS];
@@ -1435,8 +1432,6 @@ rxvt_term::run_command (const char *const *argv)
     return;
 #endif
 
-  sw_chld.start (SIGCHLD);
-
 #ifndef __QNX__
   /* spin off the command interpreter */
   switch (cmd_pid = fork ())
index 6d1af2842df587d2667bf6860e17534afaeaf53d..ddffb0dc298e975a8614aeca538ad7d5dc6963ae 100644 (file)
@@ -159,9 +159,6 @@ rxvt_term::rxvt_term ()
 #ifdef USE_XIM
     im_ev (this, &rxvt_term::im_cb),
 #endif
-    sw_term (this, &rxvt_term::sig_term),
-    sw_int (this, &rxvt_term::sig_term),
-    sw_chld (this, &rxvt_term::sig_chld),
     termwin_ev (this, &rxvt_term::x_cb),
     vt_ev (this, &rxvt_term::x_cb),
     check_ev (this, &rxvt_term::check_cb),
@@ -440,22 +437,7 @@ rxvt_xioerror_handler (Display *display)
   _exit (EXIT_FAILURE);
 }
 
-/*
- * Catch a fatal signal and tidy up before quitting
- */
-void
-rxvt_term::sig_term (sig_watcher &w)
-{
-#ifdef DEBUG_CMD
-  rxvt_warn ("caught signal %d, exiting.\n", w.signum);
-#endif
-  rxvt_emergency_cleanup ();
-  signal (w.signum, SIG_DFL);
-  kill (getpid (), w.signum);
-}
-
 /*----------------------------------------------------------------------*/
-/* rxvt_init () */
 bool
 rxvt_term::init (int argc, const char *const *argv)
 {
@@ -527,6 +509,46 @@ rxvt_term::init (int argc, const char *const *argv)
   return true;
 }
 
+static struct sig_handlers
+{
+  sig_watcher sw_chld, sw_term, sw_int;
+  
+  void sig_chld (sig_watcher &w)
+  {
+    // we are being called for every SIGCHLD, find the corresponding term
+    int pid;
+
+    while ((pid = waitpid (-1, NULL, WNOHANG)) > 0)
+      for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
+        if (pid == (*t)->cmd_pid)
+          {
+            (*t)->destroy ();
+            break;
+          }
+  }
+
+  /*
+   * Catch a fatal signal and tidy up before quitting
+   */
+  void
+  sig_term (sig_watcher &w)
+  {
+#ifdef DEBUG_CMD
+    rxvt_warn ("caught signal %d, exiting.\n", w.signum);
+#endif
+    rxvt_emergency_cleanup ();
+    signal (w.signum, SIG_DFL);
+    kill (getpid (), w.signum);
+  }
+
+  sig_handlers ()
+  : sw_chld (this, &sig_handlers::sig_chld),
+    sw_term (this, &sig_handlers::sig_term),
+    sw_int  (this, &sig_handlers::sig_term)
+  {
+  }
+} sig_handlers;
+
 void
 rxvt_init ()
 {
@@ -543,6 +565,10 @@ rxvt_init ()
   signal (SIGHUP,  SIG_IGN);
   signal (SIGPIPE, SIG_IGN);
 
+  sig_handlers.sw_chld.start (SIGCHLD);
+  sig_handlers.sw_term.start (SIGTERM);
+  sig_handlers.sw_int.start  (SIGINT);
+
   /* need to trap SIGURG for SVR4 (Unixware) rlogin */
   /* signal (SIGURG, SIG_DFL); */
 
@@ -551,28 +577,6 @@ rxvt_init ()
   XSetIOErrorHandler (rxvt_xioerror_handler);
 }
 
-/* ------------------------------------------------------------------------- *
- *                       SIGNAL HANDLING & EXIT HANDLER                      *
- * ------------------------------------------------------------------------- */
-/*
- * Catch a SIGCHLD signal and exit if the direct child has died
- */
-
-void
-rxvt_term::sig_chld (sig_watcher &w)
-{
-  // we are being called for every SIGCHLD, not just ours
-  int pid;
-
-  while ((pid = waitpid (-1, NULL, WNOHANG)) > 0)
-    for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++)
-      if (pid == (*t)->cmd_pid)
-        {
-          (*t)->destroy ();
-          break;
-        }
-}
-
 /* ------------------------------------------------------------------------- *
  *                         MEMORY ALLOCATION WRAPPERS                        *
  * ------------------------------------------------------------------------- */
@@ -587,7 +591,7 @@ rxvt_malloc (size_t size)
   return p;
 }
 
-void           *
+void *
 rxvt_calloc (size_t number, size_t size)
 {
   void *p = calloc (number, size);
index f210eca11106f169f0e72830d2b736d302a0231c..37c098debb2e7df3b963e1d77fb765d17947b56e 100644 (file)
@@ -1281,10 +1281,6 @@ struct rxvt_term : zero_initialized, rxvt_vars {
   xevent_watcher rootwin_ev;
 #endif
 
-
-  void sig_term (sig_watcher &w); sig_watcher sw_term, sw_int;
-  void sig_chld (sig_watcher &w); sig_watcher sw_chld;
-
   void x_cb (XEvent &xev);
   xevent_watcher termwin_ev;
   xevent_watcher vt_ev;