From: root Date: Wed, 30 Nov 2005 21:05:39 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=e4d4c6b2f30278affdcfb6b22372434ad36e4223;p=dana%2Furxvt.git *** empty log message *** --- diff --git a/src/init.C b/src/init.C index 728d14ff..e0da5eea 100644 --- a/src/init.C +++ b/src/init.C @@ -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 ()) diff --git a/src/main.C b/src/main.C index 6d1af284..ddffb0dc 100644 --- a/src/main.C +++ b/src/main.C @@ -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); diff --git a/src/rxvt.h b/src/rxvt.h index f210eca1..37c098de 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -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;