diff options
| author | Jim Blandy | 1993-01-14 15:07:32 +0000 |
|---|---|---|
| committer | Jim Blandy | 1993-01-14 15:07:32 +0000 |
| commit | 40be253a3beaad98e64d3dc765ff3ae39c6de0b3 (patch) | |
| tree | 0f61c148a558b865b5210615295018d128808e36 | |
| parent | 7e1fc708f4a2017f95ebfa4697446b94eea1b22c (diff) | |
| download | emacs-40be253a3beaad98e64d3dc765ff3ae39c6de0b3.tar.gz emacs-40be253a3beaad98e64d3dc765ff3ae39c6de0b3.zip | |
* emacs.c (shut_down_emacs): New function.
(fatal_error_signal, Fkill_emacs): Call it, instead of writing it out.
* xterm.c (x_connection_closed): Call shut_down_emacs instead of
Fkill_emacs; the latter will try to perform operations on the X
server and die a horrible death.
* lisp.h (shut_down_emacs): Add extern declaration for it.
| -rw-r--r-- | src/emacs.c | 105 |
1 files changed, 60 insertions, 45 deletions
diff --git a/src/emacs.c b/src/emacs.c index 14c803f2b39..da5916990d5 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | /* Fully extensible Emacs, running on Unix, intended for GNU. | 1 | /* Fully extensible Emacs, running on Unix, intended for GNU. |
| 2 | Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc. | 2 | Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
| 6 | GNU Emacs is free software; you can redistribute it and/or modify | 6 | GNU Emacs is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 1, or (at your option) | 8 | the Free Software Foundation; either version 2, or (at your option) |
| 9 | any later version. | 9 | any later version. |
| 10 | 10 | ||
| 11 | GNU Emacs is distributed in the hope that it will be useful, | 11 | GNU Emacs is distributed in the hope that it will be useful, |
| @@ -130,30 +130,9 @@ fatal_error_signal (sig) | |||
| 130 | 130 | ||
| 131 | fatal_error_in_progress = 1; | 131 | fatal_error_in_progress = 1; |
| 132 | 132 | ||
| 133 | /* If we are controlling the terminal, reset terminal modes */ | 133 | shut_down_emacs (sig); |
| 134 | #ifdef EMACS_HAVE_TTY_PGRP | ||
| 135 | { | ||
| 136 | int tpgrp; | ||
| 137 | if (EMACS_GET_TTY_PGRP (0, &tpgrp) != -1 | ||
| 138 | && tpgrp == getpgrp (0)) | ||
| 139 | { | ||
| 140 | reset_sys_modes (); | ||
| 141 | if (sig != SIGTERM) | ||
| 142 | fprintf (stderr, "Fatal error (%d).", sig); | ||
| 143 | } | ||
| 144 | } | ||
| 145 | #endif /* uses pgrp */ | ||
| 146 | |||
| 147 | /* Clean up */ | ||
| 148 | kill_buffer_processes (Qnil); | ||
| 149 | Fdo_auto_save (Qt, Qnil); | ||
| 150 | |||
| 151 | #ifdef CLASH_DETECTION | ||
| 152 | unlock_all_files (); | ||
| 153 | #endif /* CLASH_DETECTION */ | ||
| 154 | 134 | ||
| 155 | #ifdef VMS | 135 | #ifdef VMS |
| 156 | kill_vms_processes (); | ||
| 157 | LIB$STOP (SS$_ABORT); | 136 | LIB$STOP (SS$_ABORT); |
| 158 | #else | 137 | #else |
| 159 | /* Signal the same code; this time it will really be fatal. */ | 138 | /* Signal the same code; this time it will really be fatal. */ |
| @@ -618,21 +597,6 @@ all of which are called before Emacs is actually killed.") | |||
| 618 | if (!NILP (Vrun_hooks) && !noninteractive) | 597 | if (!NILP (Vrun_hooks) && !noninteractive) |
| 619 | call1 (Vrun_hooks, intern ("kill-emacs-hook")); | 598 | call1 (Vrun_hooks, intern ("kill-emacs-hook")); |
| 620 | 599 | ||
| 621 | kill_buffer_processes (Qnil); | ||
| 622 | |||
| 623 | #ifdef VMS | ||
| 624 | kill_vms_processes (); | ||
| 625 | #endif /* VMS */ | ||
| 626 | |||
| 627 | Fdo_auto_save (Qt, Qnil); | ||
| 628 | |||
| 629 | #ifdef CLASH_DETECTION | ||
| 630 | unlock_all_files (); | ||
| 631 | #endif /* CLASH_DETECTION */ | ||
| 632 | |||
| 633 | fflush (stdout); | ||
| 634 | reset_sys_modes (); | ||
| 635 | |||
| 636 | #ifdef HAVE_X_WINDOWS | 600 | #ifdef HAVE_X_WINDOWS |
| 637 | if (!noninteractive && EQ (Vwindow_system, intern ("x"))) | 601 | if (!noninteractive && EQ (Vwindow_system, intern ("x"))) |
| 638 | Fx_close_current_connection (); | 602 | Fx_close_current_connection (); |
| @@ -646,12 +610,9 @@ all of which are called before Emacs is actually killed.") | |||
| 646 | stop_vms_input (); | 610 | stop_vms_input (); |
| 647 | #endif */ | 611 | #endif */ |
| 648 | stuff_buffered_input (arg); | 612 | stuff_buffered_input (arg); |
| 649 | #ifdef SIGIO | 613 | |
| 650 | /* There is a tendency for a SIGIO signal to arrive within exit, | 614 | shut_down_emacs (0); |
| 651 | and cause a SIGHUP because the input descriptor is already closed. */ | 615 | |
| 652 | unrequest_sigio (); | ||
| 653 | signal (SIGIO, SIG_IGN); | ||
| 654 | #endif | ||
| 655 | exit ((XTYPE (arg) == Lisp_Int) ? XINT (arg) | 616 | exit ((XTYPE (arg) == Lisp_Int) ? XINT (arg) |
| 656 | #ifdef VMS | 617 | #ifdef VMS |
| 657 | : 1 | 618 | : 1 |
| @@ -661,6 +622,60 @@ all of which are called before Emacs is actually killed.") | |||
| 661 | ); | 622 | ); |
| 662 | /* NOTREACHED */ | 623 | /* NOTREACHED */ |
| 663 | } | 624 | } |
| 625 | |||
| 626 | |||
| 627 | /* Perform an orderly shutdown of Emacs. Autosave any modified | ||
| 628 | buffers, kill any child processes, clean up the terminal modes (if | ||
| 629 | we're in the foreground), and other stuff like that. Don't perform | ||
| 630 | any redisplay; this may be called when Emacs is shutting down in | ||
| 631 | the background, or after its X connection has died. | ||
| 632 | |||
| 633 | If SIG is a signal number, print a message for it. | ||
| 634 | |||
| 635 | This is called by fatal signal handlers, X protocol error handlers, | ||
| 636 | and Fkill_emacs. */ | ||
| 637 | void | ||
| 638 | shut_down_emacs (sig) | ||
| 639 | int sig; | ||
| 640 | { | ||
| 641 | /* If we are controlling the terminal, reset terminal modes */ | ||
| 642 | #ifdef EMACS_HAVE_TTY_PGRP | ||
| 643 | { | ||
| 644 | int tpgrp; | ||
| 645 | if (EMACS_GET_TTY_PGRP (0, &tpgrp) != -1 | ||
| 646 | && tpgrp == getpgrp (0)) | ||
| 647 | { | ||
| 648 | fflush (stdout); | ||
| 649 | reset_sys_modes (); | ||
| 650 | if (sig && sig != SIGTERM) | ||
| 651 | fprintf (stderr, "Fatal error (%d).", sig); | ||
| 652 | } | ||
| 653 | } | ||
| 654 | #else | ||
| 655 | fflush (stdout); | ||
| 656 | reset_sys_modes (); | ||
| 657 | #endif | ||
| 658 | |||
| 659 | kill_buffer_processes (Qnil); | ||
| 660 | Fdo_auto_save (Qt, Qnil); | ||
| 661 | |||
| 662 | #ifdef CLASH_DETECTION | ||
| 663 | unlock_all_files (); | ||
| 664 | #endif | ||
| 665 | |||
| 666 | #ifdef VMS | ||
| 667 | kill_vms_processes (); | ||
| 668 | #endif | ||
| 669 | |||
| 670 | #ifdef SIGIO | ||
| 671 | /* There is a tendency for a SIGIO signal to arrive within exit, | ||
| 672 | and cause a SIGHUP because the input descriptor is already closed. */ | ||
| 673 | unrequest_sigio (); | ||
| 674 | signal (SIGIO, SIG_IGN); | ||
| 675 | #endif | ||
| 676 | } | ||
| 677 | |||
| 678 | |||
| 664 | 679 | ||
| 665 | #ifndef CANNOT_DUMP | 680 | #ifndef CANNOT_DUMP |
| 666 | /* Nothing like this can be implemented on an Apollo. | 681 | /* Nothing like this can be implemented on an Apollo. |