… | |
… | |
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 |
290 | void |
292 | void |
291 | rxvt_term::child_exit () |
293 | rxvt_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 | } |
… | |
… | |
459 | |
463 | |
460 | #ifdef KEYSYM_RESOURCE |
464 | #ifdef KEYSYM_RESOURCE |
461 | keyboard->register_done (); |
465 | keyboard->register_done (); |
462 | #endif |
466 | #endif |
463 | |
467 | |
|
|
468 | #if ENABLE_PERL |
|
|
469 | if (!rs[Rs_perl_ext_1]) |
|
|
470 | rs[Rs_perl_ext_1] = "default"; |
|
|
471 | |
|
|
472 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
|
|
473 | || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) |
|
|
474 | || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) |
|
|
475 | { |
|
|
476 | rxvt_perl.init (this); |
|
|
477 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
|
|
478 | } |
|
|
479 | #endif |
|
|
480 | |
464 | #ifdef HAVE_SCROLLBARS |
481 | #ifdef HAVE_SCROLLBARS |
465 | if (OPTION (Opt_scrollBar)) |
482 | if (OPTION (Opt_scrollBar)) |
466 | scrollBar.setIdle (); /* set existence for size calculations */ |
483 | scrollBar.setIdle (); /* set existence for size calculations */ |
467 | #endif |
484 | #endif |
468 | |
485 | |
469 | #if ENABLE_PERL |
|
|
470 | if (!rs[Rs_perl_ext_1]) |
|
|
471 | rs[Rs_perl_ext_1] = "default"; |
|
|
472 | |
|
|
473 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
|
|
474 | || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) |
|
|
475 | || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) |
|
|
476 | { |
|
|
477 | rxvt_perl.init (this); |
|
|
478 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
|
|
479 | } |
|
|
480 | #endif |
|
|
481 | |
|
|
482 | pty = rxvt_new_ptytty (); |
486 | pty = rxvt_new_ptytty (); |
483 | |
487 | |
484 | create_windows (argc, argv); |
488 | create_windows (argc, argv); |
485 | |
489 | |
486 | dDisp; |
490 | dDisp; |
… | |
… | |
525 | return true; |
529 | return true; |
526 | } |
530 | } |
527 | |
531 | |
528 | static struct sig_handlers |
532 | static 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); */ |