ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/main.C
(Generate patch)

Comparing rxvt-unicode/src/main.C (file contents):
Revision 1.188 by root, Wed Jan 18 08:33:34 2006 UTC vs.
Revision 1.189 by root, Thu Jan 19 09:47:15 2006 UTC

169#ifdef USE_XIM 169#ifdef USE_XIM
170 im_ev (this, &rxvt_term::im_cb), 170 im_ev (this, &rxvt_term::im_cb),
171#endif 171#endif
172 termwin_ev (this, &rxvt_term::x_cb), 172 termwin_ev (this, &rxvt_term::x_cb),
173 vt_ev (this, &rxvt_term::x_cb), 173 vt_ev (this, &rxvt_term::x_cb),
174 child_ev (this, &rxvt_term::child_cb),
174 check_ev (this, &rxvt_term::check_cb), 175 check_ev (this, &rxvt_term::check_cb),
175 flush_ev (this, &rxvt_term::flush_cb), 176 flush_ev (this, &rxvt_term::flush_cb),
176 destroy_ev (this, &rxvt_term::destroy_cb), 177 destroy_ev (this, &rxvt_term::destroy_cb),
177 pty_ev (this, &rxvt_term::pty_cb), 178 pty_ev (this, &rxvt_term::pty_cb),
178 incr_ev (this, &rxvt_term::incr_cb) 179 incr_ev (this, &rxvt_term::incr_cb)
285#ifdef KEYSYM_RESOURCE 286#ifdef KEYSYM_RESOURCE
286 delete keyboard; 287 delete keyboard;
287#endif 288#endif
288} 289}
289 290
291// child has exited, usually destroys
290void 292void
291rxvt_term::child_exit () 293rxvt_term::child_cb (child_watcher &w, int status)
292{ 294{
295 HOOK_INVOKE ((this, HOOK_CHILD_EXIT, DT_INT, status, DT_END));
296
293 cmd_pid = 0; 297 cmd_pid = 0;
294 298
295 if (!OPTION (Opt_hold)) 299 if (!OPTION (Opt_hold))
296 destroy (); 300 destroy ();
297} 301}
525 return true; 529 return true;
526} 530}
527 531
528static struct sig_handlers 532static struct sig_handlers
529{ 533{
530 sig_watcher sw_chld, sw_term, sw_int; 534 sig_watcher sw_term, sw_int;
531 535
532 void sig_chld (sig_watcher &w)
533 {
534 // we are being called for every SIGCHLD, find the corresponding term
535 int pid;
536
537 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0)
538 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
539 if (pid == (*t)->cmd_pid)
540 {
541 (*t)->child_exit ();
542 break;
543 }
544 }
545
546 /* 536 /*
547 * Catch a fatal signal and tidy up before quitting 537 * Catch a fatal signal and tidy up before quitting
548 */ 538 */
549 void 539 void
550 sig_term (sig_watcher &w) 540 sig_term (sig_watcher &w)
556 signal (w.signum, SIG_DFL); 546 signal (w.signum, SIG_DFL);
557 kill (getpid (), w.signum); 547 kill (getpid (), w.signum);
558 } 548 }
559 549
560 sig_handlers () 550 sig_handlers ()
561 : sw_chld (this, &sig_handlers::sig_chld),
562 sw_term (this, &sig_handlers::sig_term), 551 : sw_term (this, &sig_handlers::sig_term),
563 sw_int (this, &sig_handlers::sig_term) 552 sw_int (this, &sig_handlers::sig_term)
564 { 553 {
565 } 554 }
566} sig_handlers; 555} sig_handlers;
567 556
604 rxvt_environ = environ; 593 rxvt_environ = environ;
605 594
606 signal (SIGHUP, SIG_IGN); 595 signal (SIGHUP, SIG_IGN);
607 signal (SIGPIPE, SIG_IGN); 596 signal (SIGPIPE, SIG_IGN);
608 597
609 sig_handlers.sw_chld.start (SIGCHLD);
610 sig_handlers.sw_term.start (SIGTERM); 598 sig_handlers.sw_term.start (SIGTERM);
611 sig_handlers.sw_int.start (SIGINT); 599 sig_handlers.sw_int.start (SIGINT);
612 600
613 /* need to trap SIGURG for SVR4 (Unixware) rlogin */ 601 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
614 /* signal (SIGURG, SIG_DFL); */ 602 /* signal (SIGURG, SIG_DFL); */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines