/* Fully extensible Emacs, running on Unix, intended for GNU.
- Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc.
+ Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <sys/ioctl.h>
#endif
+#ifdef HAVE_TERMIOS
+#include <termios.h>
+#endif
+
#ifdef APOLLO
#ifndef APOLLO_SR10
#include <default_acl.h>
#endif
#endif
-#undef NULL
#include "lisp.h"
#include "commands.h"
+#include "systerm.h"
+
#ifndef O_RDWR
#define O_RDWR 2
#endif
/* Command line args from shell, as list of strings */
Lisp_Object Vcommand_line_args;
+/* Hook run by `kill-emacs' before it does really anything. */
+Lisp_Object Vkill_emacs_hook;
+
/* Set nonzero after Emacs has started up the first time.
Prevents reinitialization of the Lisp world and keymaps
on subsequent starts. */
int fatal_error_in_progress;
/* Handle bus errors, illegal instruction, etc. */
+SIGTYPE
fatal_error_signal (sig)
int sig;
{
-#ifdef BSD
- int tpgrp;
-#endif /* BSD */
-
fatal_error_code = sig;
signal (sig, SIG_DFL);
fatal_error_in_progress = 1;
/* If we are controlling the terminal, reset terminal modes */
-#ifdef BSD
- if (ioctl(0, TIOCGPGRP, &tpgrp) == 0
- && tpgrp == getpgrp (0))
-#endif /* BSD */
- {
- reset_sys_modes ();
- if (sig != SIGTERM)
- fprintf (stderr, "Fatal error (%d).", sig);
- }
+#ifdef EMACS_HAVE_TTY_PGRP
+ {
+ int tpgrp;
+ if (EMACS_GET_TTY_PGRP (0, &tpgrp) != -1
+ && tpgrp == getpgrp (0))
+ {
+ reset_sys_modes ();
+ if (sig != SIGTERM)
+ fprintf (stderr, "Fatal error (%d).", sig);
+ }
+ }
+#endif /* uses pgrp */
/* Clean up */
-#ifdef subprocesses
kill_buffer_processes (Qnil);
-#endif
Fdo_auto_save (Qt, Qnil);
#ifdef CLASH_DETECTION
inhibit_window_system = 0;
-/* Handle the -t switch, which specifies filename to use as terminal */
+ /* Handle the -t switch, which specifies filename to use as terminal */
if (skip_args + 2 < argc && !strcmp (argv[skip_args + 1], "-t"))
{
int result;
}
init_alloc ();
-#ifdef MAINTAIN_ENVIRONMENT
- init_environ ();
-#endif
init_eval ();
init_data ();
init_lread ();
#ifdef VMS
init_vmsfns ();
#endif /* VMS */
-#ifdef subprocesses
init_process ();
-#endif /* subprocesses */
+#ifdef CLASH_DETECTION
+ init_filelock ();
+#endif /* CLASH_DETECTION */
/* Intern the names of all standard functions and variables; define standard keys */
for the sake of symbols like error-message */
syms_of_data ();
syms_of_alloc ();
-#ifdef MAINTAIN_ENVIRONMENT
- syms_of_environ ();
-#endif /* MAINTAIN_ENVIRONMENT */
syms_of_lread ();
syms_of_print ();
syms_of_eval ();
syms_of_marker ();
syms_of_minibuf ();
syms_of_mocklisp ();
-#ifdef subprocesses
syms_of_process ();
-#endif /* subprocesses */
syms_of_search ();
#ifdef MULTI_SCREEN
syms_of_screen ();
syms_of_window ();
syms_of_xdisp ();
#ifdef HAVE_X_WINDOWS
+ syms_of_xterm ();
syms_of_xfns ();
+#ifdef HAVE_X11
+ syms_of_xselect ();
+#endif
#ifdef HAVE_X_MENU
syms_of_xmenu ();
#endif /* HAVE_X_MENU */
if (feof (stdin))
arg = Qt;
- if (!NULL (Vrun_hooks) && !noninteractive)
+ if (!NILP (Vrun_hooks) && !noninteractive)
call1 (Vrun_hooks, intern ("kill-emacs-hook"));
-#ifdef subprocesses
kill_buffer_processes (Qnil);
-#endif /* subprocesses */
#ifdef VMS
kill_vms_processes ();
CHECK_STRING (intoname, 0);
intoname = Fexpand_file_name (intoname, Qnil);
- if (!NULL (symname))
+ if (!NILP (symname))
{
CHECK_STRING (symname, 0);
if (XSTRING (symname)->size)
malloc_init (&my_edata, malloc_warning);
#endif
unexec (XSTRING (intoname)->data,
- !NULL (symname) ? XSTRING (symname)->data : 0, &my_edata, 0, 0);
+ !NILP (symname) ? XSTRING (symname)->data : 0, &my_edata, 0, 0);
#endif /* not VMS */
Vpurify_flag = tem;
Lisp_Object lpath;
- path = (char *) egetenv (evarname);
+ /* It's okay to use getenv here, because this function is only used
+ to initialize variables when Emacs starts up, and isn't called
+ after that. */
+ if (evarname != 0)
+ path = (char *) getenv (evarname);
+ else
+ path = 0;
if (!path)
path = defalt;
lpath = Qnil;
DEFVAR_BOOL ("noninteractive", &noninteractive1,
"Non-nil means Emacs is running without interactive terminal.");
+
+ Vkill_emacs_hook = Qnil;
+
+ DEFVAR_LISP ("kill-emacs-hook", &Vkill_emacs_hook,
+ "Hook to be run whenever kill-emacs is called.");
}