Mercurial > hg > xemacs-beta
comparison src/emacs.c @ 408:501cfd01ee6d r21-2-34
Import from CVS: tag r21-2-34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:18:11 +0200 |
parents | b8cc9ab3f761 |
children | de805c49cfc1 |
comparison
equal
deleted
inserted
replaced
407:ed6218a7d4d3 | 408:501cfd01ee6d |
---|---|
1 /* XEmacs -- Fully extensible Emacs, running on Unix and other platforms. | 1 /* XEmacs -- Fully extensible Emacs, running on Unix and other platforms. |
2 Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994 | 2 Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 Copyright (C) 1995 Sun Microsystems, Inc. | 4 Copyright (C) 1995 Sun Microsystems, Inc. |
5 Copyright (C) 2000 Ben Wing. | |
5 | 6 |
6 This file is part of XEmacs. | 7 This file is part of XEmacs. |
7 | 8 |
8 XEmacs is free software; you can redistribute it and/or modify it | 9 XEmacs is free software; you can redistribute it and/or modify it |
9 under the terms of the GNU General Public License as published by the | 10 under the terms of the GNU General Public License as published by the |
19 along with XEmacs; see the file COPYING. If not, write to | 20 along with XEmacs; see the file COPYING. If not, write to |
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 Boston, MA 02111-1307, USA. */ | 22 Boston, MA 02111-1307, USA. */ |
22 | 23 |
23 /* Synched up with: Mule 2.0, FSF 19.28. */ | 24 /* Synched up with: Mule 2.0, FSF 19.28. */ |
25 | |
26 /* Capsule summary of the various releases of Lucid Emacs/XEmacs and | |
27 FSF/GNU Emacs. Provided here for use in cross-referencing version | |
28 releases and dates in comments, esp. in the authorship comments at | |
29 the beginning of each file. More information about history can be | |
30 found in the beginning of the Internals Manual and in the About page. | |
31 | |
32 | |
33 -- A time line for Lucid Emacs/XEmacs is | |
34 | |
35 version 19.0 shipped with Energize 1.0, April 1992. | |
36 version 19.1 released June 4, 1992. | |
37 version 19.2 released June 19, 1992. | |
38 version 19.3 released September 9, 1992. | |
39 version 19.4 released January 21, 1993. | |
40 version 19.5 was a repackaging of 19.4 with a few bug fixes and | |
41 shipped with Energize 2.0. Never released to the net. | |
42 version 19.6 released April 9, 1993. | |
43 version 19.7 was a repackaging of 19.6 with a few bug fixes and | |
44 shipped with Energize 2.1. Never released to the net. | |
45 version 19.8 released September 6, 1993. | |
46 version 19.9 released January 12, 1994. | |
47 version 19.10 released May 27, 1994. | |
48 version 19.11 (first XEmacs) released September 13, 1994. | |
49 version 19.12 released June 23, 1995. | |
50 version 19.13 released September 1, 1995. | |
51 version 19.14 released June 23, 1996. | |
52 version 20.0 released February 9, 1997. | |
53 version 19.15 released March 28, 1997. | |
54 version 20.1 (not released to the net) April 15, 1997. | |
55 version 20.2 released May 16, 1997. | |
56 version 19.16 released October 31, 1997. | |
57 version 20.3 (the first stable version of XEmacs 20.x) released | |
58 November 30, 1997. | |
59 version 20.4 released February 28, 1998. | |
60 | |
61 | |
62 -- A time line for GNU Emacs version 19 is | |
63 | |
64 version 19.7 (beta) (first beta release) released ??????; prob. late May 1993. | |
65 version 19.8 (beta) released May 27, 1993. | |
66 version 19.9 (beta) released May 27, 1993. | |
67 version 19.10 (beta) released May 30, 1993. | |
68 version 19.11 (beta) released June 1, 1993. | |
69 version 19.12 (beta) released June 2, 1993. | |
70 version 19.13 (beta) released June 8, 1993. | |
71 version 19.14 (beta) released June 17, 1993. | |
72 version 19.15 (beta) released June 19, 1993. | |
73 version 19.16 (beta) released July 6, 1993. | |
74 version 19.17 (beta) released late July, 1993. | |
75 version 19.18 (beta) released August 9, 1993. | |
76 version 19.19 (beta) released August 15, 1993. | |
77 version 19.20 (beta) released November 17, 1993. | |
78 version 19.21 (beta) released November 17, 1993. | |
79 version 19.22 (beta) released November 28, 1993. | |
80 version 19.23 (beta) released May 17, 1994. | |
81 version 19.24 (beta) released May 16, 1994. | |
82 version 19.25 (beta) released June 3, 1994. | |
83 version 19.26 (beta) released September 11, 1994. | |
84 version 19.27 (beta) released September 14, 1994. | |
85 version 19.28 (first ``official'' release) released November 1, 1994. | |
86 version 19.29 released June 21, 1995. | |
87 version 19.30 released November 24, 1995. | |
88 version 19.31 released May 25, 1996. | |
89 version 19.32 released July 31, 1996. | |
90 version 19.33 released August 11, 1996. | |
91 version 19.34 released August 21, 1996. | |
92 version 19.34b released September 6, 1996. | |
93 | |
94 | |
95 -- A time line for GNU Emacs version 20 is | |
96 | |
97 version 20.1 released September 17, 1997. | |
98 version 20.2 released September 20, 1997. | |
99 version 20.3 released August 19, 1998. | |
100 | |
101 | |
102 -- A time line for GNU Emacs version 18 and older is | |
103 | |
104 GNU Emacs version 15 (15.34) was released sometime in 1984 or 1985 and | |
105 shared some code with a version of Emacs written by James Gosling (the | |
106 same James Gosling who later created the Java language). | |
107 GNU Emacs version 16 (first released version was 16.56) was released on | |
108 July 15, 1985. All Gosling code was removed due to potential copyright | |
109 problems with the code. | |
110 version 16.57: released on September 16, 1985. | |
111 versions 16.58, 16.59: released on September 17, 1985. | |
112 version 16.60: released on September 19, 1985. These later version 16's | |
113 incorporated patches from the net, esp. for getting Emacs to work under | |
114 System V. | |
115 version 17.36 (first official v17 release) released on December 20, 1985. | |
116 Included a TeX-able user manual. First official unpatched version that | |
117 worked on vanilla System V machines. | |
118 version 17.43 (second official v17 release) released on January 25, 1986. | |
119 version 17.45 released on January 30, 1986. | |
120 version 17.46 released on February 4, 1986. | |
121 version 17.48 released on February 10, 1986. | |
122 version 17.49 released on February 12, 1986. | |
123 version 17.55 released on March 18, 1986. | |
124 version 17.57 released on March 27, 1986. | |
125 version 17.58 released on April 4, 1986. | |
126 version 17.61 released on April 12, 1986. | |
127 version 17.63 released on May 7, 1986. | |
128 version 17.64 released on May 12, 1986. | |
129 version 18.24 (a beta version) released on October 2, 1986. | |
130 version 18.30 (a beta version) released on November 15, 1986. | |
131 version 18.31 (a beta version) released on November 23, 1986. | |
132 version 18.32 (a beta version) released on December 7, 1986. | |
133 version 18.33 (a beta version) released on December 12, 1986. | |
134 version 18.35 (a beta version) released on January 5, 1987. | |
135 version 18.36 (a beta version) released on January 21, 1987. | |
136 January 27, 1987: The Great Usenet Renaming. net.emacs is now comp.emacs. | |
137 version 18.37 (a beta version) released on February 12, 1987. | |
138 version 18.38 (a beta version) released on March 3, 1987. | |
139 version 18.39 (a beta version) released on March 14, 1987. | |
140 version 18.40 (a beta version) released on March 18, 1987. | |
141 version 18.41 (the first ``official'' release) released on March 22, 1987. | |
142 version 18.45 released on June 2, 1987. | |
143 version 18.46 released on June 9, 1987. | |
144 version 18.47 released on June 18, 1987. | |
145 version 18.48 released on September 3, 1987. | |
146 version 18.49 released on September 18, 1987. | |
147 version 18.50 released on February 13, 1988. | |
148 version 18.51 released on May 7, 1988. | |
149 version 18.52 released on September 1, 1988. | |
150 version 18.53 released on February 24, 1989. | |
151 version 18.54 released on April 26, 1989. | |
152 version 18.55 released on August 23, 1989. This is the earliest version | |
153 that is still available by FTP. | |
154 version 18.56 released on January 17, 1991. | |
155 version 18.57 released late January, 1991. | |
156 version 18.58 released ?????. | |
157 version 18.59 released October 31, 1992. | |
158 | |
159 */ | |
24 | 160 |
25 /* Note: It is necessary to specify <config.h> and not "config.h" in | 161 /* Note: It is necessary to specify <config.h> and not "config.h" in |
26 order for the --srcdir type of compilation to work properly. | 162 order for the --srcdir type of compilation to work properly. |
27 Otherwise the config.h from the srcdir, rather than the one from | 163 Otherwise the config.h from the srcdir, rather than the one from |
28 the build dir, will be used. */ | 164 the build dir, will be used. */ |
168 /* If nonzero, set XEmacs to run at this priority. This is also used | 304 /* If nonzero, set XEmacs to run at this priority. This is also used |
169 in child_setup and sys_suspend to make sure subshells run at normal | 305 in child_setup and sys_suspend to make sure subshells run at normal |
170 priority. */ | 306 priority. */ |
171 int emacs_priority; | 307 int emacs_priority; |
172 | 308 |
173 /* If non-zero a filter or a sentinel is running. Tested to save the match | 309 /* Some FSF junk with running_asynch_code, to preserve the match |
174 data on the first attempt to change it inside asynchronous code. */ | 310 data. Not necessary because we don't call process filters |
311 asynchronously (i.e. from within QUIT). */ | |
312 /* #### Delete this when merging the rest of my code */ | |
175 int running_asynch_code; | 313 int running_asynch_code; |
176 | 314 |
177 /* If non-zero, a window-system was specified on the command line. */ | 315 /* If non-zero, a window-system was specified on the command line. */ |
178 int display_arg; | 316 int display_arg; |
179 | 317 |
239 Lisp_Object Qsave_buffers_kill_emacs; | 377 Lisp_Object Qsave_buffers_kill_emacs; |
240 | 378 |
241 extern Lisp_Object Vlisp_EXEC_SUFFIXES; | 379 extern Lisp_Object Vlisp_EXEC_SUFFIXES; |
242 | 380 |
243 | 381 |
244 /* Signal code for the fatal signal that was received */ | 382 |
245 static int fatal_error_code; | 383 /* Ben's capsule summary about expected and unexpected exits from XEmacs. |
246 | 384 |
247 /* Nonzero if handling a fatal error already */ | 385 Expected exits occur when the user directs XEmacs to exit, for example |
248 static int fatal_error_in_progress; | 386 by pressing the close button on the only frame in XEmacs, or by typing |
387 C-x C-c. This runs `save-buffers-kill-emacs', which saves any necessary | |
388 buffers, and then exits using the primitive `kill-emacs'. | |
389 | |
390 However, unexpected exits occur in a few different ways: | |
391 | |
392 -- a memory access violation or other hardware-generated exception | |
393 occurs. This is the worst possible problem to deal with, because | |
394 the fault can occur while XEmacs is in any state whatsoever, even | |
395 quite unstable ones. As a result, we need to be *extremely* careful | |
396 what we do. | |
397 -- we are using one X display (or if we've used more, we've closed the | |
398 others already), and some hardware or other problem happens and | |
399 suddenly we've lost our connection to the display. In this situation, | |
400 things are not so dire as in the last one; our code itself isn't | |
401 trashed, so we can continue execution as normal, after having set | |
402 things up so that we can exit at the appropriate time. Our exit | |
403 still needs to be of the emergency nature; we have no displays, so | |
404 any attempts to use them will fail. We simply want to auto-save | |
405 (the single most important thing to do during shut-down), do minimal | |
406 cleanup of stuff that has an independent existence outside of XEmacs, | |
407 and exit. | |
408 | |
409 Currently, both unexpected exit scenarios described above set | |
410 preparing_for_armageddon to indicate that nonessential and possibly | |
411 dangerous things should not be done, specifically: | |
412 | |
413 -- no garbage collection. | |
414 -- no hooks are run. | |
415 -- no messages of any sort from autosaving. | |
416 -- autosaving tries harder, ignoring certain failures. | |
417 -- existing frames are not deleted. | |
418 | |
419 (Also, all places that set preparing_for_armageddon also | |
420 set dont_check_for_quit. This happens separately because it's | |
421 also necessary to set other variables to make absolutely sure | |
422 no quitting happens.) | |
423 | |
424 In the first scenario above (the access violation), we also set | |
425 fatal_error_in_progress. This causes more things to not happen: | |
426 | |
427 -- assertion failures do not abort. | |
428 -- printing code does not do code conversion or gettext when | |
429 printing to stdout/stderr. | |
430 */ | |
431 | |
432 /* Nonzero if handling a fatal error already. */ | |
433 int fatal_error_in_progress; | |
434 | |
435 /* Non-nil means we're going down, so we better not run any hooks | |
436 or do other non-essential stuff. */ | |
437 int preparing_for_armageddon; | |
438 | |
249 | 439 |
250 static JMP_BUF run_temacs_catch; | 440 static JMP_BUF run_temacs_catch; |
251 | 441 |
252 static int run_temacs_argc; | 442 static int run_temacs_argc; |
253 static char **run_temacs_argv; | 443 static char **run_temacs_argv; |
254 static char *run_temacs_args; | 444 static char *run_temacs_args; |
255 static size_t run_temacs_argv_size; | 445 static size_t run_temacs_argv_size; |
256 static size_t run_temacs_args_size; | 446 static size_t run_temacs_args_size; |
257 | 447 |
258 static void shut_down_emacs (int sig, Lisp_Object stuff); | 448 static void shut_down_emacs (int sig, Lisp_Object stuff, int no_auto_save); |
449 | |
450 static void | |
451 ensure_no_quitting_from_now_on (void) | |
452 { | |
453 /* make sure no quitting from now on!! */ | |
454 dont_check_for_quit = 1; | |
455 Vinhibit_quit = Qt; | |
456 Vquit_flag = Qnil; | |
457 } | |
259 | 458 |
260 /* Handle bus errors, illegal instruction, etc. */ | 459 /* Handle bus errors, illegal instruction, etc. */ |
261 SIGTYPE | 460 SIGTYPE |
262 fatal_error_signal (int sig) | 461 fatal_error_signal (int sig) |
263 { | 462 { |
264 fatal_error_code = sig; | 463 fatal_error_in_progress++; |
265 signal (sig, SIG_DFL); | 464 preparing_for_armageddon = 1; |
465 | |
466 ensure_no_quitting_from_now_on (); | |
467 | |
266 /* Unblock the signal so that if the same signal gets sent in the | 468 /* Unblock the signal so that if the same signal gets sent in the |
267 code below, we avoid a deadlock. */ | 469 code below, we avoid a deadlock. */ |
268 EMACS_UNBLOCK_SIGNAL (fatal_error_code); | 470 EMACS_UNBLOCK_SIGNAL (sig); |
269 | 471 |
472 /* Only try auto-saving first time through. If we crash in auto-saving, | |
473 don't do it again. */ | |
474 if (fatal_error_in_progress == 1) | |
475 { | |
476 Fdo_auto_save (Qt, Qnil); /* do this before anything hazardous */ | |
477 /* Do this so that the variable has the same value of 2 regardless of | |
478 whether we made it through auto-saving correctly. */ | |
479 fatal_error_in_progress++; | |
480 } | |
481 else if (fatal_error_in_progress == 2) | |
482 stderr_out ("WARNING: Unable to auto-save your files properly.\n" | |
483 "Some or all may in fact have been auto-saved.\n" | |
484 "\n"); | |
485 | |
486 /* Now, reset our signal handler, so the next time, we just die. | |
487 Don't do this before auto-saving. */ | |
488 signal (sig, SIG_DFL); | |
489 | |
490 /* Keep in mind that there's more than one signal that we can crash | |
491 on. */ | |
270 /* If fatal error occurs in code below, avoid infinite recursion. */ | 492 /* If fatal error occurs in code below, avoid infinite recursion. */ |
271 if (! fatal_error_in_progress) | 493 if (fatal_error_in_progress <= 2) |
272 { | 494 { |
273 fatal_error_in_progress = dont_check_for_quit = 1; | 495 shut_down_emacs (sig, Qnil, 1); |
274 shut_down_emacs (sig, Qnil); | |
275 stderr_out ("\nLisp backtrace follows:\n\n"); | 496 stderr_out ("\nLisp backtrace follows:\n\n"); |
276 Fbacktrace (Qexternal_debugging_output, Qt); | 497 Fbacktrace (Qexternal_debugging_output, Qt); |
277 # if 0 /* This is evil, rarely useful, and causes grief in some cases. */ | 498 # if 0 /* This is evil, rarely useful, and causes grief in some cases. */ |
278 /* Check for Sun-style stack printing via /proc */ | 499 /* Check for Sun-style stack printing via /proc */ |
279 { | 500 { |
288 } | 509 } |
289 } | 510 } |
290 # endif | 511 # endif |
291 } | 512 } |
292 /* Signal the same code; this time it will really be fatal. */ | 513 /* Signal the same code; this time it will really be fatal. */ |
293 kill (getpid (), fatal_error_code); | 514 kill (getpid (), sig); |
294 SIGRETURN; | 515 SIGRETURN; |
295 } | 516 } |
517 | |
518 #ifdef _MSC_VER | |
519 | |
520 static DWORD | |
521 mswindows_handle_hardware_exceptions (DWORD code) | |
522 { | |
523 if (code != STATUS_ACCESS_VIOLATION && code != STATUS_ILLEGAL_INSTRUCTION | |
524 && code != STATUS_PRIVILEGED_INSTRUCTION | |
525 && code != STATUS_DATATYPE_MISALIGNMENT) | |
526 return EXCEPTION_CONTINUE_SEARCH; | |
527 | |
528 /* I don't know if this filter is still wrapped in the outer __try, but | |
529 it doesn't hurt to have another one. --ben */ | |
530 __try | |
531 { | |
532 fatal_error_in_progress++; | |
533 preparing_for_armageddon = 1; | |
534 | |
535 ensure_no_quitting_from_now_on (); | |
536 | |
537 /* Only try auto-saving first time through. If we crash in auto-saving, | |
538 don't do it again. */ | |
539 if (fatal_error_in_progress == 1) | |
540 { | |
541 Fdo_auto_save (Qt, Qnil); /* do this before anything hazardous */ | |
542 /* Do this so that the variable has the same value of 2 regardless of | |
543 whether we made it through auto-saving correctly. */ | |
544 fatal_error_in_progress++; | |
545 } | |
546 else if (fatal_error_in_progress == 2) | |
547 stderr_out ("WARNING: Unable to auto-save your files properly.\n" | |
548 "Some or all may in fact have been auto-saved.\n" | |
549 "\n"); | |
550 | |
551 /* If fatal error occurs in code below, avoid infinite recursion. */ | |
552 if (fatal_error_in_progress <= 2) | |
553 { | |
554 shut_down_emacs (-1, Qnil, 1); | |
555 stderr_out ("\nLisp backtrace follows:\n\n"); | |
556 Fbacktrace (Qexternal_debugging_output, Qt); | |
557 } | |
558 } | |
559 /* VC++ documentation says that | |
560 GetExceptionCode() cannot be called inside the filter itself. */ | |
561 __except (mswindows_handle_hardware_exceptions (GetExceptionCode ())) {} | |
562 | |
563 /* pretend we didn't handle this, so that the debugger is invoked and/or | |
564 the normal GPF box appears. */ | |
565 return EXCEPTION_CONTINUE_SEARCH; | |
566 } | |
567 | |
568 #endif /* _MSC_VER */ | |
569 | |
296 | 570 |
297 | 571 |
298 #ifdef SIGDANGER | 572 #ifdef SIGDANGER |
299 | 573 |
300 /* Handler for SIGDANGER. */ | 574 /* Handler for SIGDANGER. */ |
1684 #ifdef HAVE_SHLIB | 1958 #ifdef HAVE_SHLIB |
1685 reinit_vars_of_module (); | 1959 reinit_vars_of_module (); |
1686 #endif | 1960 #endif |
1687 reinit_vars_of_objects (); | 1961 reinit_vars_of_objects (); |
1688 reinit_vars_of_print (); | 1962 reinit_vars_of_print (); |
1689 reinit_vars_of_redisplay (); | |
1690 reinit_vars_of_search (); | 1963 reinit_vars_of_search (); |
1691 reinit_vars_of_undo (); | 1964 reinit_vars_of_undo (); |
1692 reinit_vars_of_window (); | 1965 reinit_vars_of_window (); |
1693 | 1966 |
1694 #ifdef HAVE_MS_WINDOWS | 1967 #ifdef HAVE_MS_WINDOWS |
2171 | 2444 |
2172 /* ARGSUSED */ | 2445 /* ARGSUSED */ |
2173 int | 2446 int |
2174 main (int argc, char **argv, char **envp) | 2447 main (int argc, char **argv, char **envp) |
2175 { | 2448 { |
2449 | |
2450 #ifdef _MSC_VER | |
2451 /* Under VC++, access violations and the like are not sent through | |
2452 the standard signal() mechanism. Rather, they need to be handled | |
2453 using the Microsoft "structured exception handling" mechanism, | |
2454 which vaguely resembles the C++ mechanisms. */ | |
2455 __try | |
2456 { | |
2457 #endif | |
2458 | |
2176 int volatile vol_argc = argc; | 2459 int volatile vol_argc = argc; |
2177 char ** volatile vol_argv = argv; | 2460 char ** volatile vol_argv = argv; |
2178 char ** volatile vol_envp = envp; | 2461 char ** volatile vol_envp = envp; |
2179 /* This is hairy. We need to compute where the XEmacs binary was invoked | 2462 /* This is hairy. We need to compute where the XEmacs binary was invoked |
2180 from because temacs initialization requires it to find the lisp | 2463 from because temacs initialization requires it to find the lisp |
2288 #endif /* DOUG_LEA_MALLOC */ | 2571 #endif /* DOUG_LEA_MALLOC */ |
2289 | 2572 |
2290 run_temacs_argc = -1; | 2573 run_temacs_argc = -1; |
2291 | 2574 |
2292 main_1 (vol_argc, vol_argv, vol_envp, restarted); | 2575 main_1 (vol_argc, vol_argv, vol_envp, restarted); |
2576 | |
2577 #ifdef _MSC_VER | |
2578 } | |
2579 /* VC++ documentation says that | |
2580 GetExceptionCode() cannot be called inside the filter itself. */ | |
2581 __except (mswindows_handle_hardware_exceptions (GetExceptionCode ())) {} | |
2582 #endif | |
2583 | |
2293 return 0; /* unreached */ | 2584 return 0; /* unreached */ |
2294 } | 2585 } |
2295 | 2586 |
2296 | 2587 |
2297 /* Dumping apparently isn't supported by versions of GCC >= 2.8. */ | 2588 /* Dumping apparently isn't supported by versions of GCC >= 2.8. */ |
2332 arg = Qt; | 2623 arg = Qt; |
2333 | 2624 |
2334 if (!preparing_for_armageddon && !noninteractive) | 2625 if (!preparing_for_armageddon && !noninteractive) |
2335 run_hook (Qkill_emacs_hook); | 2626 run_hook (Qkill_emacs_hook); |
2336 | 2627 |
2337 /* make sure no quitting from now on!! */ | 2628 ensure_no_quitting_from_now_on (); |
2338 dont_check_for_quit = 1; | |
2339 Vinhibit_quit = Qt; | |
2340 | 2629 |
2341 if (!preparing_for_armageddon) | 2630 if (!preparing_for_armageddon) |
2342 { | 2631 { |
2343 Lisp_Object concons, nextcons; | 2632 Lisp_Object concons, nextcons; |
2344 | 2633 |
2362 } | 2651 } |
2363 } | 2652 } |
2364 | 2653 |
2365 UNGCPRO; | 2654 UNGCPRO; |
2366 | 2655 |
2367 shut_down_emacs (0, STRINGP (arg) ? arg : Qnil); | 2656 shut_down_emacs (0, STRINGP (arg) ? arg : Qnil, 0); |
2368 | 2657 |
2369 #if defined(GNU_MALLOC) | 2658 #if defined(GNU_MALLOC) |
2370 __free_hook = | 2659 __free_hook = |
2371 #ifdef __GNUC__ /* prototype of __free_hook varies with glibc version */ | 2660 #ifdef __GNUC__ /* prototype of __free_hook varies with glibc version */ |
2372 (__typeof__ (__free_hook)) | 2661 (__typeof__ (__free_hook)) |
2385 any redisplay; this may be called when XEmacs is shutting down in | 2674 any redisplay; this may be called when XEmacs is shutting down in |
2386 the background, or after its X connection has died. | 2675 the background, or after its X connection has died. |
2387 | 2676 |
2388 If SIG is a signal number, print a message for it. | 2677 If SIG is a signal number, print a message for it. |
2389 | 2678 |
2390 This is called by fatal signal handlers, X protocol error handlers, | 2679 This is called by fatal signal handlers and Fkill_emacs. It used to |
2391 and Fkill_emacs. */ | 2680 be called by X protocol error handlers, but instead they now call |
2681 Fkill_emacs. */ | |
2392 static void | 2682 static void |
2393 shut_down_emacs (int sig, Lisp_Object stuff) | 2683 shut_down_emacs (int sig, Lisp_Object stuff, int no_auto_save) |
2394 { | 2684 { |
2395 /* This function can GC */ | 2685 /* This function can GC */ |
2396 /* Prevent running of hooks and other non-essential stuff | 2686 /* Prevent running of hooks and other non-essential stuff |
2397 from now on. */ | 2687 from now on. */ |
2398 preparing_for_armageddon = 1; | 2688 preparing_for_armageddon = 1; |
2399 | 2689 |
2400 /* In case frames or windows are screwed up, avoid assertion | 2690 ensure_no_quitting_from_now_on (); |
2401 failures here */ | |
2402 Vinhibit_quit = Qt; | |
2403 | 2691 |
2404 #ifdef QUANTIFY | 2692 #ifdef QUANTIFY |
2405 quantify_stop_recording_data (); | 2693 quantify_stop_recording_data (); |
2406 #endif /* QUANTIFY */ | 2694 #endif /* QUANTIFY */ |
2407 | 2695 |
2408 #if 0 | |
2409 /* This is absolutely the most important thing to do, so make sure | 2696 /* This is absolutely the most important thing to do, so make sure |
2410 we do it now, before anything else. We might have crashed and | 2697 we do it now, before anything else. We might have crashed and |
2411 be in a weird inconsistent state, and potentially anything could | 2698 be in a weird inconsistent state, and potentially anything could |
2412 set off another protection fault and cause us to bail out | 2699 set off another protection fault and cause us to bail out |
2413 immediately. */ | 2700 immediately. */ |
2414 /* I'm not removing the code entirely, yet. We have run up against | 2701 /* Steve writes the following: |
2702 | |
2703 [[I'm not removing the code entirely, yet. We have run up against | |
2415 a spate of problems in diagnosing crashes due to crashes within | 2704 a spate of problems in diagnosing crashes due to crashes within |
2416 crashes. It has very definitely been determined that code called | 2705 crashes. It has very definitely been determined that code called |
2417 during auto-saving cannot work if XEmacs crashed inside of GC. | 2706 during auto-saving cannot work if XEmacs crashed inside of GC. |
2418 We already auto-save on an itimer so there cannot be too much | 2707 We already auto-save on an itimer so there cannot be too much |
2419 unsaved stuff around, and if we get better crash reports we might | 2708 unsaved stuff around, and if we get better crash reports we might |
2420 be able to get more problems fixed so I'm disabling this. -slb */ | 2709 be able to get more problems fixed so I'm disabling this. -slb]] |
2421 Fdo_auto_save (Qt, Qnil); /* do this before anything hazardous */ | 2710 |
2422 #endif | 2711 and DISABLES AUTO-SAVING ENTIRELY during crashes! Way way bad idea. |
2712 | |
2713 Instead let's just be more intelligent about avoiding crashing | |
2714 when possible, esp. nested crashes. | |
2715 */ | |
2716 if (!no_auto_save) | |
2717 Fdo_auto_save (Qt, Qnil); /* do this before anything hazardous */ | |
2423 | 2718 |
2424 fflush (stdout); | 2719 fflush (stdout); |
2425 reset_all_consoles (); | 2720 reset_all_consoles (); |
2426 if (sig && sig != SIGTERM) | 2721 if (sig && sig != SIGTERM) |
2427 { | 2722 { |
2428 stderr_out ("\nFatal error (%d).\n", sig); | 2723 if (sig == -1) |
2724 stderr_out ("\nFatal error.\n\n"); | |
2725 else | |
2726 stderr_out ("\nFatal error (%d).\n\n", sig); | |
2429 stderr_out | 2727 stderr_out |
2430 ("Your files have been auto-saved.\n" | 2728 ("Your files have been auto-saved.\n" |
2431 "Use `M-x recover-session' to recover them.\n" | 2729 "Use `M-x recover-session' to recover them.\n" |
2432 "\n" | 2730 "\n" |
2433 "If you have access to the PROBLEMS file that came with your\n" | 2731 "If you have access to the PROBLEMS file that came with your\n" |
2442 "from the help menu.\n" | 2740 "from the help menu.\n" |
2443 "As a last resort send ordinary email to `crashes@xemacs.org'.\n" | 2741 "As a last resort send ordinary email to `crashes@xemacs.org'.\n" |
2444 #endif | 2742 #endif |
2445 "*MAKE SURE* to include the information in the command\n" | 2743 "*MAKE SURE* to include the information in the command\n" |
2446 "M-x describe-installation.\n" | 2744 "M-x describe-installation.\n" |
2745 #ifndef _MSC_VER | |
2447 "\n" | 2746 "\n" |
2448 "If at all possible, *please* try to obtain a C stack backtrace;\n" | 2747 "If at all possible, *please* try to obtain a C stack backtrace;\n" |
2449 "it will help us immensely in determining what went wrong.\n" | 2748 "it will help us immensely in determining what went wrong.\n" |
2450 "To do this, locate the core file that was produced as a result\n" | 2749 "To do this, locate the core file that was produced as a result\n" |
2451 "of this crash (it's usually called `core' and is located in the\n" | 2750 "of this crash (it's usually called `core' and is located in the\n" |
2452 "directory in which you started the editor, or maybe in your home\n" | 2751 "directory in which you started the editor, or maybe in your home\n" |
2453 "directory), and type\n" | 2752 "directory), and type\n" |
2454 "\n" | 2753 "\n" |
2455 " gdb "); | 2754 " gdb " |
2755 #endif | |
2756 ); | |
2757 #ifndef _MSC_VER | |
2456 { | 2758 { |
2457 const char *name; | 2759 const char *name; |
2458 char *dir = 0; | 2760 char *dir = 0; |
2459 | 2761 |
2460 /* Now try to determine the actual path to the executable, | 2762 /* Now try to determine the actual path to the executable, |
2477 (" core\n\n" | 2779 (" core\n\n" |
2478 "then type `where' when the debugger prompt comes up.\n" | 2780 "then type `where' when the debugger prompt comes up.\n" |
2479 "(If you don't have GDB on your system, you might have DBX,\n" | 2781 "(If you don't have GDB on your system, you might have DBX,\n" |
2480 "or XDB, or SDB. A similar procedure should work for all of\n" | 2782 "or XDB, or SDB. A similar procedure should work for all of\n" |
2481 "these. Ask your system administrator if you need more help.)\n"); | 2783 "these. Ask your system administrator if you need more help.)\n"); |
2784 #endif /* _MSC_VER */ | |
2482 } | 2785 } |
2483 | 2786 |
2484 stuff_buffered_input (stuff); | 2787 stuff_buffered_input (stuff); |
2485 | 2788 |
2486 kill_buffer_processes (Qnil); | 2789 kill_buffer_processes (Qnil); |
2740 /* #define ASSERTIONS_DONT_ABORT */ | 3043 /* #define ASSERTIONS_DONT_ABORT */ |
2741 | 3044 |
2742 #ifdef USE_ASSERTIONS | 3045 #ifdef USE_ASSERTIONS |
2743 /* This highly dubious kludge ... shut up Jamie, I'm tired of your slagging. */ | 3046 /* This highly dubious kludge ... shut up Jamie, I'm tired of your slagging. */ |
2744 | 3047 |
2745 DOESNT_RETURN | 3048 static int in_assert_failed; |
3049 static const char *assert_failed_file; | |
3050 static int assert_failed_line; | |
3051 static const char *assert_failed_expr; | |
3052 | |
3053 #ifdef fprintf | |
3054 #undef fprintf | |
3055 #endif | |
3056 | |
3057 #undef abort /* avoid infinite #define loop... */ | |
3058 | |
3059 #if defined (WINDOWSNT) && defined (DEBUG_XEMACS) | |
3060 #define enter_debugger() DebugBreak () | |
3061 #else | |
3062 #define enter_debugger() | |
3063 #endif | |
3064 | |
3065 void | |
2746 assert_failed (const char *file, int line, const char *expr) | 3066 assert_failed (const char *file, int line, const char *expr) |
2747 { | 3067 { |
2748 stderr_out ("Fatal error: assertion failed, file %s, line %d, %s\n", | 3068 /* If we're already crashing, let's not crash again. This might be |
2749 file, line, expr); | 3069 critical to getting auto-saving working properly. */ |
2750 #undef abort /* avoid infinite #define loop... */ | 3070 if (fatal_error_in_progress) |
2751 #if defined (WINDOWSNT) && defined (DEBUG_XEMACS) | 3071 return; |
2752 DebugBreak (); | 3072 |
2753 #elif !defined (ASSERTIONS_DONT_ABORT) | 3073 /* We are extremely paranoid so we sensibly deal with recursive |
3074 assertion failures. */ | |
3075 in_assert_failed++; | |
3076 | |
3077 if (in_assert_failed >= 4) | |
3078 _exit (-1); | |
3079 else if (in_assert_failed == 3) | |
3080 { | |
3081 enter_debugger (); | |
3082 _exit (-1); | |
3083 } | |
3084 else if (in_assert_failed == 2) | |
3085 { | |
3086 /* Not stderr_out(), which does additional things and may trigger | |
3087 a recursive assertion failure. fprintf was undeffed above, in | |
3088 case it was encapsulated. */ | |
3089 fprintf (stderr, | |
3090 "Fatal error: recursive assertion failure, " | |
3091 "file %s, line %d, %s\n", | |
3092 file, line, expr); | |
3093 fprintf (stderr, | |
3094 "Original assertion failure: file %s, line %d, %s\n", | |
3095 assert_failed_file, assert_failed_line, assert_failed_expr); | |
3096 } | |
3097 else | |
3098 { | |
3099 assert_failed_file = file; | |
3100 assert_failed_line = line; | |
3101 assert_failed_expr = expr; | |
3102 | |
3103 if (!initialized) | |
3104 fprintf (stderr, | |
3105 "Fatal error: assertion failed, file %s, line %d, %s\n", | |
3106 file, line, expr); | |
3107 else | |
3108 stderr_out ("Fatal error: assertion failed, file %s, line %d, %s\n", | |
3109 file, line, expr); | |
3110 } | |
3111 | |
3112 enter_debugger (); | |
3113 #if !defined (ASSERTIONS_DONT_ABORT) | |
2754 abort (); | 3114 abort (); |
2755 #endif | 3115 #endif |
3116 in_assert_failed = 0; | |
2756 } | 3117 } |
2757 #endif /* USE_ASSERTIONS */ | 3118 #endif /* USE_ASSERTIONS */ |
2758 | 3119 |
2759 #ifdef QUANTIFY | 3120 #ifdef QUANTIFY |
2760 DEFUN ("quantify-start-recording-data", Fquantify_start_recording_data, | 3121 DEFUN ("quantify-start-recording-data", Fquantify_start_recording_data, |
3174 *List of directories of architecture-independent files that come with XEmacs | 3535 *List of directories of architecture-independent files that come with XEmacs |
3175 or were installed as packages, and are intended for XEmacs to use. | 3536 or were installed as packages, and are intended for XEmacs to use. |
3176 */ ); | 3537 */ ); |
3177 Vdata_directory_list = Qnil; | 3538 Vdata_directory_list = Qnil; |
3178 | 3539 |
3179 #ifdef CLASH_DETECTION | |
3180 DEFVAR_LISP ("configure-lock-directory", &Vconfigure_lock_directory /* | |
3181 For internal use by the build procedure only. | |
3182 configure's idea of what LOCK-DIRECTORY will be. | |
3183 */ ); | |
3184 #ifdef PATH_LOCK | |
3185 Vconfigure_lock_directory = Ffile_name_as_directory | |
3186 (build_string ((char *) PATH_LOCK)); | |
3187 #else | |
3188 Vconfigure_lock_directory = Qnil; | |
3189 #endif | |
3190 #endif /* CLASH_DETECTION */ | |
3191 | |
3192 DEFVAR_LISP ("site-directory", &Vsite_directory /* | 3540 DEFVAR_LISP ("site-directory", &Vsite_directory /* |
3193 *Directory of site-specific Lisp files that come with XEmacs. | 3541 *Directory of site-specific Lisp files that come with XEmacs. |
3194 */ ); | 3542 */ ); |
3195 Vsite_directory = Qnil; | 3543 Vsite_directory = Qnil; |
3196 | 3544 |