aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris <[email protected]>2010-10-01 19:30:11 -0700
committerGlenn Morris <[email protected]>2010-10-01 19:30:11 -0700
commit9c524fcb89871b321844de7297a1baee0bde0376 (patch)
tree8be5dae3c4db4410ab1be600696164b7a5bfb020
parent08b8ba9fae180c04036b748d5838a5768b013c1d (diff)
Run kill-emacs-hook in batch mode, and on SIGINT in batch mode.
See thread http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg00795.html * src/emacs.c (fatal_error_signal): Also run Fkill_emacs on SIGINT. (main) [!WINDOWSNT]: Handle SIGINT with fatal_error_signal in batch-mode. (Fkill_emacs): Doc fix. Also run the hook in batch mode. (kill-emacs-hook): Doc fix. * lisp/emacs-lisp/bytecomp.el (byte-compile-file): Use kill-emacs-hook to delete tempfile if interrupted during compilation. * doc/lispref/os.texi (Killing Emacs): Hook now runs in batch mode. * etc/NEWS: Mention these changes.
-rw-r--r--doc/lispref/ChangeLog4
-rw-r--r--doc/lispref/os.texi1
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/emacs-lisp/bytecomp.el15
-rw-r--r--src/ChangeLog8
-rw-r--r--src/emacs.c18
7 files changed, 46 insertions, 10 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index ec065e9ce7..dfa070e70b 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,7 @@
+2010-10-02 Glenn Morris <[email protected]>
+
+ * os.texi (Killing Emacs): Hook now runs in batch mode.
+
2010-09-18 Stefan Monnier <[email protected]>
* text.texi (Special Properties): Clarify when modification-hooks run.
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index dd82723427..8548ce0504 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -577,7 +577,6 @@ does not run the remaining functions in this hook. Calling
This variable is a normal hook; once @code{save-buffers-kill-emacs} is
finished with all file saving and confirmation, it calls
@code{kill-emacs} which runs the functions in this hook.
-@code{kill-emacs} does not run this hook in batch mode.
@code{kill-emacs} may be invoked directly (that is not via
@code{save-buffers-kill-emacs}) if the terminal is disconnected, or in
diff --git a/etc/NEWS b/etc/NEWS
index e6ada72c07..71cdcb2a64 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -149,6 +149,11 @@ get and set the SELinux context of a file.
*** Tramp offers handlers for file-selinux-context and set-file-selinux-context
for remote machines which support SELinux.
+** The function kill-emacs is now run upon receipt of the signals SIGTERM
+and SIGHUP, and (except on MS-Windows) SIGINT in batch mode.
+
+** kill-emacs-hook is now also run in batch mode.
+
** New scrolling commands `scroll-up-command' and `scroll-down-command'
(bound to C-v/[next] and M-v/[prior]) does not signal errors at top/bottom
of buffer at first key-press (instead moves to top/bottom of buffer)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 235aec2f47..b780f0b0fd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2010-10-02 Glenn Morris <[email protected]>
+
+ * emacs-lisp/bytecomp.el (byte-compile-file): Use kill-emacs-hook to
+ delete tempfile if interrupted during compilation.
+
2010-10-01 Lars Magne Ingebrigtsen <[email protected]>
* net/tls.el (tls-starttls-switches): Give up on using starttls with
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index e6ca7f6654..56661b6afc 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1698,12 +1698,15 @@ The value is non-nil if there were no errors, nil if errors."
(insert "\n") ; aaah, unix.
(if (file-writable-p target-file)
;; We must disable any code conversion here.
- (let ((coding-system-for-write 'no-conversion)
- ;; Write to a tempfile so that if another Emacs
- ;; process is trying to load target-file (eg in a
- ;; parallel bootstrap), it does not risk getting a
- ;; half-finished file. (Bug#4196)
- (tempfile (make-temp-name target-file)))
+ (let* ((coding-system-for-write 'no-conversion)
+ ;; Write to a tempfile so that if another Emacs
+ ;; process is trying to load target-file (eg in a
+ ;; parallel bootstrap), it does not risk getting a
+ ;; half-finished file. (Bug#4196)
+ (tempfile (make-temp-name target-file))
+ (kill-emacs-hook
+ (cons (lambda () (ignore-errors (delete-file tempfile)))
+ kill-emacs-hook)))
(if (memq system-type '(ms-dos 'windows-nt))
(setq buffer-file-type t))
(write-region (point-min) (point-max) tempfile nil 1)
diff --git a/src/ChangeLog b/src/ChangeLog
index 70a7d43c32..a87b0bc49c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2010-10-02 Glenn Morris <[email protected]>
+
+ * emacs.c (fatal_error_signal): Also run Fkill_emacs on SIGINT.
+ (main) [!WINDOWSNT]: Handle SIGINT with fatal_error_signal
+ in batch-mode.
+ (Fkill_emacs): Doc fix. Also run the hook in batch mode.
+ (kill-emacs-hook): Doc fix.
+
2010-10-02 Lars Magne Ingebrigtsen <[email protected]>
* xml.c (Flibxml_parse_xml_region, Flibxml_parse_html_region)
diff --git a/src/emacs.c b/src/emacs.c
index 397b6d1ce8..7eba690cb8 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -378,7 +378,7 @@ fatal_error_signal (int sig)
{
fatal_error_in_progress = 1;
- if (sig == SIGTERM || sig == SIGHUP)
+ if (sig == SIGTERM || sig == SIGHUP || sig == SIGINT)
Fkill_emacs (make_number (sig));
shut_down_emacs (sig, 0, Qnil);
@@ -1240,6 +1240,14 @@ main (int argc, char **argv)
#ifdef SIGSYS
signal (SIGSYS, fatal_error_signal);
#endif
+#ifndef WINDOWSNT
+ /* May need special treatment on MS-Windows. See
+ http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg01062.html
+ Please update the doc of kill-emacs, kill-emacs-hook, and
+ NEWS if you change this.
+ */
+ if ( noninteractive ) signal (SIGINT, fatal_error_signal);
+#endif
signal (SIGTERM, fatal_error_signal);
#ifdef SIGXCPU
signal (SIGXCPU, fatal_error_signal);
@@ -1988,6 +1996,9 @@ DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P",
If ARG is an integer, return ARG as the exit program code.
If ARG is a string, stuff it as keyboard input.
+This function is called upon receipt of the signals SIGTERM
+or SIGHUP, and (except on MS-Windows) SIGINT in batch mode.
+
The value of `kill-emacs-hook', if not void,
is a list of functions (of no args),
all of which are called before Emacs is actually killed. */)
@@ -2000,7 +2011,7 @@ all of which are called before Emacs is actually killed. */)
if (feof (stdin))
arg = Qt;
- if (!NILP (Vrun_hooks) && !noninteractive)
+ if (!NILP (Vrun_hooks))
call1 (Vrun_hooks, intern ("kill-emacs-hook"));
UNGCPRO;
@@ -2421,7 +2432,8 @@ in other similar situations), functions placed on this hook should not
expect to be able to interact with the user. To ask for confirmation,
see `kill-emacs-query-functions' instead.
-The hook is not run in batch mode, i.e., if `noninteractive' is non-nil. */);
+Before Emacs 24.1, the hook was not run in batch mode, i.e., if
+`noninteractive' was non-nil. */);
Vkill_emacs_hook = Qnil;
DEFVAR_INT ("emacs-priority", &emacs_priority,