view src/emacs.c @ 1284:4742a5797146

Password: Last login: Tue Sep 29 20:00:25 from paris.CS.Berkele 4.3 BSD UNIX #1: Fri Dec 1 20:30:54 EST 1989 This machine belongs to the GNU project. Feel free to use it. Send questions, requests, or other remarks to request@gnu.ai.mit.edu The GNU Project does not have the physical resources to "host" random games and IRC daemons on its machines. They tie up computing resources needed to develop software and further GNU. They have become a real hassle for us, so please don't run them. /home/fsg is full. Do the right thing. Guests: please don't use the hp300 machines for games, IRC, or news. You are welcome to use them for other purposes as long as a staff member doesn't ask you to log out and use another host. The hp300s include wookumz, churchy, geech, and mole. Machines which may be used for just about any purpose include hal, wombat, kropotkin, goldman, and hill. You have mail. This is a -bash login shell. No DISPLAY variable here... jla@churchy$ pwd /home/fsf/jla jla@churchy$ cd src /gd/gnu/emacs/19.0/src jla@churchy$ gdb xemacs GDB is free software and you are welcome to distribute copies of it under certain conditions; type "show copying" to see the conditions. There is absolutely no warranty for GDB; type "show warranty" for details. GDB 4.6, Copyright 1992 Free Software Foundation, Inc... TERMCAP and TERM environment variables unset. Environment variable "DISPLAY" not defined. Breakpoint 1 at 0x7d6ec Breakpoint 2 at 0x77310 (gdb) set env DISPLAY 128.32.150.43:0.0 (gdb) r Starting program: /home/gd/gnu/emacs/19.0/src/xemacs -q Cannot insert breakpoint 1: The same program may be running in another process. Cannot access memory at address 0x7d6ec. (gdb) [1]+ Stopped gdb xemacs jla@churchy$ ps x PID TT STAT TIME COMMAND 29053 p7 S 0:05 -bash (bash) 29074 p7 T 0:04 gdb xemacs 29075 p7 T 0:00 /home/gd/gnu/emacs/19.0/src/xemacs -q 29076 p7 R 0:00 ps x jla@churchy$ ps ax PID TT STAT TIME COMMAND 0 ? D 0:36 swapper 1 ? I 0:01 init 2 ? D 0:03 pagedaemon 49 ? S 15:02 syslogd 50 ? I 0:58 portmap 60 ? I 0:12 -accepting connections (sendmail) 64 ? S < 0:53 /usr/local/etc/ntpd 67 ? I 0:01 /usr/bin/X11/xdm 97 ? I 0:19 cron 101 ? S 2:22 /usr/etc/rwhod 103 ? I 2:45 /etc/inetd 106 ? IW 0:00 /usr/lib/lpd 145 ? IW 0:00 (nfsd) 146 ? IW 0:00 (nfsd) 147 ? IW 0:00 (nfsd) 148 ? IW 0:00 (nfsd) 152 ? IW 1:38 (biod) 153 ? IW 1:40 (biod) 154 ? IW 1:41 (biod) 155 ? IW 1:40 (biod) 2925 ? IW 0:00 rpc.mountd 5255 ? I 11:14 ibble 24806 ? S 19:37 /usr/bin/X11/X :0 28913 ? I 0:00 -:0 (xdm) 28924 ? I 0:01 sh /home/fsf/melissa/.xinitrc 28932 ? I 0:00 xterm -C -ut +sb -n Console -geometry 80x24+1+0 28933 ? I 0:00 xbiff -geometry -140+180 28934 ? S 0:02 xclock -analog -geometry -0+180 28935 ? S 0:02 xclock -digital -geometry 85x17-0+280 28936 ? I 0:54 emacs -wn Mail -in Mail -geometry 80x55+35+18 -f rmail -fon 28937 ? I 0:01 twm 28940 ? I 0:00 /usr/local/lib/emacs/etc/wakeup 60 28951 ? I 0:11 emacs -d :0.0 -w 28952 ? I 0:00 /usr/local/lib/emacs/etc/wakeup 60 29024 ? I 0:09 emacs -d :0.0 -w 29025 ? I 0:00 /usr/local/lib/emacs/etc/wakeup 60 29045 ? I 0:00 -AA29035 mizzou1.missouri.edu: user open (sendmail) 28938 p0 I 0:00 bash 28942 p1 I 0:00 /usr/local/gnubin/bash -i 28943 p2 I 0:00 -sh (csh) 28953 p3 I 0:00 /usr/local/gnubin/bash -i 28954 p4 I 0:00 -sh (csh) 29026 p5 I 0:00 /usr/local/gnubin/bash -i 560 p6 I 0:08 .nbin/mr 29027 p6 I 0:00 -sh (csh) 29052 p7 S 0:00 rlogind 29053 p7 S 0:05 -bash (bash) 29074 p7 T 0:04 gdb xemacs 29075 p7 T 0:00 /home/gd/gnu/emacs/19.0/src/xemacs -q 29077 p7 R 0:00 ps ax 5256 q0 IW 0:00 -bin/csh (csh) 5272 q0 S 6:38 tf2 5261 q1 IW 0:00 -bin/csh (csh) 5266 q2 IW 0:00 -bin/csh (csh) 15329 q2 I 7:27 emacs -f gnus 15330 q2 I 0:01 /usr/local/lib/emacs/etc/wakeup 60 95 ? S 2:22 update 157 ? IW 0:00 - 300h console (getty) jla@churchy$ fg gdb xemacs (gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /home/gd/gnu/emacs/19.0/src/xemacs -q Cannot insert breakpoint 1: The same program may be running in another process. Cannot access memory at address 0x7d6ec. (gdb) dis (gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /home/gd/gnu/emacs/19.0/src/xemacs -q Program received signal 2, Interrupt 0x83ffe in select () (gdb) b Fsignal Breakpoint 3 at 0x503da: file eval.c, line 1105. (gdb) c Continuing. Cannot insert breakpoint 3: The same program may be running in another process. Cannot access memory at address 0x503da. (gdb) dis (gdb) c Continuing. Program received signal 2, Interrupt 0x83ffe in select () (gdb) k` Kill the inferior process? (y or n) y (gdb) q jla@churchy$ who jla ttyp7 Sep 30 14:10 (priam.CS.Berkele) melissa :0 Sep 30 13:41 jla@churchy$ ll *emacs* -rwxrwxrwx 1 jimb daemon 2464158 Sep 27 23:33 emacs-19.0.437* -rwxrwxrwx 1 jimb daemon 2464135 Sep 28 02:19 emacs-19.0.438* -rwxrwxrwx 1 rms daemon 2464283 Sep 28 09:08 emacs-19.0.439* -rwxrwxrwx 1 jimb daemon 2464480 Sep 29 00:59 emacs-19.0.440* -rwxrwxrwx 1 jimb daemon 2465827 Sep 29 09:24 emacs-19.0.444* -rwxrwxrwx 1 jimb daemon 2466058 Sep 29 10:16 emacs-19.0.445* -rwxrwxrwx 1 jimb daemon 2466058 Sep 29 10:35 emacs-19.0.446* -rwxrwxrwx 1 jimb daemon 2466070 Sep 29 13:18 emacs-19.0.447* -rwxrwxrwx 1 jimb daemon 2462257 Sep 30 11:00 emacs-19.0.448* -rwxrwxrwx 2 jimb daemon 2462209 Sep 30 11:16 emacs-19.0.449* -rwxrwxrwx 1 jimb daemon 2462194 Sep 30 11:57 emacs-19.0.450* -rwxrwxrwx 2 jimb daemon 2466524 Sep 30 12:19 emacs-19.0.451* -r--r--r-- 1 jimb daemon 20265 Sep 22 23:40 emacs.c -rw-rw-rw- 1 rms daemon 18316 Sep 23 08:15 emacs.o -rwxrwxrwx 1 jimb daemon 2466070 Sep 29 14:36 jimb-xemacs* -rwxrwxrwx 1 jimb daemon 2097884 Sep 30 12:17 temacs* -rwxrwxrwx 1 jimb daemon 1822178 Sep 13 09:31 temacs-2* -rw-rw-rw- 1 jimb daemon 784 Sep 18 1988 temacs.opt -rw-rw-rw- 1 jimb daemon 177 Feb 26 1987 testemacs.com -rwxrwxrwx 2 jimb daemon 2466524 Sep 30 12:19 xemacs* -rwxrwxrwx 1 jla daemon 2463040 Sep 23 17:15 yemacs* jla@churchy$ rm yemacs jla@churchy$ cp xemacs yemacs & [1] 29088 jla@churchy$ more ChangeLog Wed Sep 30 06:59:07 1992 Jim Blandy (jimb@wookumz.gnu.ai.mit.edu) * buffer.c (Fother_buffer): Add back the VISIBLE_OK argument. It got removed with no comment or ChangeLog entry, and append-to-buffer uses it. * window.c (struct save_window_data): Add a member called focus_frame, to save and restore the screen's focus frame. (Fset_window_configuration): Redirect the frame's focus as indicated in the window configuration. (Fcurrent_window_configuration): Record the frame's current focus. * minibuf.c (read_minibuf): Don't bother to save the current frame's focus, and have read_minibuf_unwind restore it; saving and restoring the window configurations will take care of that. (read_minibuf_unwind): Don't worry about restoring the frame's focus. * window.c (Fset_window_configuration): Don't select the frame just because we restored its configuration. * window.c (Fset_window_configuration): Don't forget to set the frame's selected window when we can't call Fselect_window. * xterm.c (x_meta_mod_mask): New variable, indicating which X modifier bits denote meta keys. (x_find_modifier_meanings): New function, to set x_meta_mod_mask. (x_convert_modifiers): Use that. (x_term_init): Call x_find_modifier_meanings. * data.c (Fmake_local_variable): If SYM forwards to a C variable, swap in the value for the current buffer immediately. * lisp.h: Doc elaboration for Lisp_Buffer_Local_Value. Tue Sep 29 21:05:30 1992 Joseph Arceneaux (jla@churchy.gnu.ai.mit.edu) * textprop.c (Ferase_text_properties): Merge intervals when possible. Tue Sep 29 00:04:05 1992 Jim Blandy (jimb@wookumz.gnu.ai.mit.edu) * xselect.c (Qcut_buffer0): Symbol removed; we're using a new interface to the cut buffer now. (NUM_CUT_BUFFERS, cut_buffer_atom, cut_buffer_value, cut_buffer_cached, cut_buffer_just_set): New variables. (Fx_own_selection, Fx_selection_value): Dike out the code to handle CUT_BUFFER0 requests. (Fx_get_cut_buffer, Fx_set_cut_buffer, x_watch_cut_buffer_cache, x_invalidate_cut_buffer_cache): New functions. [1]+ Exit 0 cp xemacs yemacs jla@churchy$ gdb yemacs GDB is free software and you are welcome to distribute copies of it under certain conditions; type "show copying" to see the conditions. There is absolutely no warranty for GDB; type "show warranty" for details. GDB 4.6, Copyright 1992 Free Software Foundation, Inc... TERMCAP and TERM environment variables unset. Environment variable "DISPLAY" not defined. Breakpoint 1 at 0x7d6ec Breakpoint 2 at 0x77310 (gdb) b Fsignal Breakpoint 3 at 0x503da: file eval.c, line 1105. (gdb) set env DISPLAY 128.32.150.43:0.0 (gdb) r Starting program: /home/gd/gnu/emacs/19.0/src/yemacs -q Breakpoint 3, Fsignal (sig=17759556, data=17759236) at eval.c:1105 1105 register struct handler *allhandlers = handlerlist; (gdb) c Continuing. Breakpoint 3, Fsignal (sig=17759576, data=84996828) at eval.c:1105 1105 register struct handler *allhandlers = handlerlist; (gdb) bt #0 Fsignal (sig=17759576, data=84996828) at eval.c:1105 #1 0x4664a in wrong_type_argument (predicate=17803608, value=987136) at data.c:73 #2 0x4572 in Fredirect_frame_focus (frame=987136, focus_frame=235868160) at frame.c:893 #3 0xe114 in Fset_window_configuration (configuration=353327296) at window.c:2498 #4 0x524aa in unbind_to (count=7, value=51516952) at eval.c:2111 #5 0xe61c in Fsave_window_excursion (args=84526412) at window.c:2683 #6 0x60cd4 in Fbyte_code (bytestr=50971960, vector=67749184, maxdepth=1) at bytecode.c:555 #7 0x521a8 in funcall_lambda (fun=101303552, nargs=2, arg_vector=0xffeff7ae) at eval.c:2032 #8 0x51c42 in Ffuncall (nargs=3, args=0xffeff7aa) at eval.c:1898 #9 0x607c8 in Fbyte_code (bytestr=50977256, vector=67754576, maxdepth=5) at bytecode.c:422 #10 0x521a8 in funcall_lambda (fun=101308856, nargs=1, arg_vector=0xffeff8ee) at eval.c:2032 #11 0x51c42 in Ffuncall (nargs=2, args=0xffeff8ea) at eval.c:1898 #12 0x4e980 in Fcall_interactively (function=17914640, record=17759236) at callint.c:508 #13 0x24090 in Fcommand_execute (cmd=17914640, record=17759236) at keyboard.c:3025 #14 0x21028 in command_loop_1 () at keyboard.c:973 #15 0x50370 in internal_condition_case (bfun=0x2084c <command_loop_1>, handlers=17759536, hfun=0x20304 <cmd_error>) at eval.c:1083 #16 0x2066a in command_loop_2 () at keyboard.c:701 #17 0x4fece in internal_catch (tag=17759516, func=0x2064e <command_loop_2>, arg=17759236) at eval.c:875 #18 0x2062e in command_loop () at keyboard.c:681 #19 0x201ca in recursive_edit_1 () at keyboard.c:523 #20 0x20298 in Frecursive_edit () at keyboard.c:558 #21 0x1fa36 in main (argc=2, argv=0xffeffce4, envp=0xffeffcf0) at emacs.c:581 (gdb) fr 2 #2 0x4572 in Fredirect_frame_focus (frame=987136, focus_frame=235868160) at frame.c:893 893 CHECK_LIVE_FRAME (frame, 0); (gdb) l 888 This is useful for temporarily redirecting keystrokes to the minibuffer\n\ 889 window when a frame doesn't have its own minibuffer.") 890 (frame, focus_frame) 891 Lisp_Object frame, focus_frame; 892 { 893 CHECK_LIVE_FRAME (frame, 0); 894 895 if (NILP (focus_frame)) 896 focus_frame = frame; 897 else (gdb) 898 CHECK_LIVE_FRAME (focus_frame, 1); 899 900 XFRAME (frame)->focus_frame = focus_frame; 901 902 if (frame_rehighlight_hook) 903 (*frame_rehighlight_hook) (); 904 jla@churchy$ l elisp/ jla-src/ v19-src/ jla@churchy$ cd v19-src/ jla@churchy$ grep INTERVAL lisp.h #ifdef USE_INTERVALS typedef struct interval *INTERVAL; #define DECLARE_INTERVALS INTERVAL intervals; #define INITIALIZE_INTERVAL(ptr,val) ptr->intervals = val #define INTERVAL #define DECLARE_INTERVALS #define INITIALIZE_INTERVAL(ptr,val) #endif /* USE_INTERVALS */ DECLARE_INTERVALS jla@churchy$ grep INTERVAL config.h /* Define USE_INTERVALS to handle fat text. */ #define USE_INTERVALS jla@churchy$ d /gd2/jla/v19-src jla@churchy$ pwd /home/gd2/jla/v19-src jla@churchy$ grep DECLARE_INTERVALS *.[ch] buffer.h: DECLARE_INTERVALS lisp.h:#define DECLARE_INTERVALS INTERVAL intervals; lisp.h:#define DECLARE_INTERVALS lisp.h: DECLARE_INTERVALS jla@churchy$ grep INITIALIZE_INTERVAL *.c alloc.c: INITIALIZE_INTERVAL (XSTRING (val), NULL_INTERVAL); alloc.c: INITIALIZE_INTERVAL (XSTRING (new), NULL_INTERVAL); buffer.c: INITIALIZE_INTERVAL (b, NULL_INTERVAL); buffer.c: INITIALIZE_INTERVAL (b, NULL_INTERVAL); jla@churchy$ pwd /home/gd2/jla/v19-src jla@churchy$ cd etc /gd/gnu/emacs/19.0/etc jla@churchy$ l *.c /usr/local/gnubin/ls: *.c: No such file or directory jla@churchy$ more Makefile DESTDIR= LIBDIR=/usr/local/lib BINDIR=/usr/local/bin MANDIR=/usr/man/man1 MANEXT=1 all: distclean: -rm -f *~ \#* DOC* core clean: -rm -f core jla@churchy$ cd .. jla@churchy$ l ChangeLog README.~3~ info/ ChangeLog~ README.~6~ lib-src/ GETTING.GNU.SOFTWARE README.~7~ lisp/ GETTING.GNU.SOFTWARE.~1~ arch-lib/ local-lisp/ GETTING.GNU.SOFTWARE.~2~ build-install* lock/ INSTALL build-install.in* make-dist* INSTALL.~1~ build-install.in,v* make-dist.~10~* INSTALL.~2~ config.emacs.~1~* make-dist.~11~* jla@churchy$ cd src /gd/gnu/emacs/19.0/src jla@churchy$ make -f xmakefile editfns.o make: `editfns.o' is up to date. jla@churchy$ ll editfns.[co] -rw-r--r-- 1 jla daemon 36258 Sep 30 20:39 editfns.c -rw-rw-rw- 1 jla daemon 38383 Sep 30 20:43 editfns.o jla@churchy$ date Wed Sep 30 20:45:25 EDT 1992 jla@churchy$ rm editfns.o jla@churchy$ make -f xmakefile editfns.o cc -g -Demacs -Is -Im -c editfns.c -o editfns.o jla@churchy$ lt {insdel,emacs,buffer}.[co] -rw-rw-rw- 1 jla daemon 16422 Sep 30 20:42 insdel.o -rw-rw-rw- 1 rms daemon 18316 Sep 30 20:40 emacs.o -rw-r--r-- 1 jla daemon 14931 Sep 30 19:54 insdel.c -rw-r--r-- 1 jla daemon 20387 Sep 30 19:33 emacs.c -rw-rw-rw- 1 jla daemon 44674 Sep 30 19:29 buffer.o -r--r--r-- 1 jimb daemon 56614 Sep 30 14:13 buffer.c jla@churchy$ ll buffer.h -rw-r--r-- 1 jla daemon 14323 Sep 30 18:36 buffer.h jla@churchy$ ll temacs -rw-rw-rw- 1 jimb daemon 313564 Sep 30 20:46 temacs jla@churchy$ man rcs jla@churchy$ man rlog jla@churchy$ rlog RCS/buffer.c,v RCS file: RCS/buffer.c,v Working file: buffer.c head: 1.15 branch: locks: strict access list: symbolic names: comment leader: " * " keyword substitution: kv total revisions: 15; selected revisions: 15 description: /* Buffer manipulation primitives for GNU Emacs. ---------------------------- revision 1.15 date: 1992/09/30 18:16:11; author: jimb; state: Exp; lines: +9 -5 * buffer.c (Fother_buffer): Add back the VISIBLE_OK argument. It got removed with no comment or ChangeLog entry, and append-to-buffer uses it. ---------------------------- revision 1.14 date: 1992/09/29 04:54:28; author: jimb; state: Exp; lines: +1 -1 * data.c (Frem): Use the `fmod' function under SunOS, Ultrix, and HP/UX, not just under USG systems. ---------------------------- revision 1.13 date: 1992/09/29 04:08:04; author: jimb; state: Exp; lines: +20 -14 * buffer.c (Fbury_buffer): This used to undisplay the buffer being buried only if the BUFFER argument was nil. Instead, undisplay the buffer whenever it's displayed in the selected window, no matter how it was specified by BUFFER. This is how it behaves in 18.58, and I can't find any ChangeLog entry in 18.58 or 19.0 saying why they differ. Fix the doc string accordingly. ---------------------------- revision 1.12 date: 1992/09/22 05:16:47; author: jimb; state: Exp; lines: +1 -0 * buffer.c (Fget_buffer_create): Doc fix. jla@churchy$ d /gd/gnu/emacs/19.0/src jla@churchy$ ci editfns.c insdel.c emacs.c buffer.h intervals.h intervals.c tex tprop.c RCS/editfns.c,v <-- editfns.c new revision: 1.14; previous revision: 1.13 enter log message, terminated with single '.' or end of file: >> >> * editfns.c (make_buffer_string): Call copy_intervals_to_string(). (Finsert_buffer_substring): Call graft_intervals_into_buffer(). #include "intervals.h". >> >> >> . done RCS/insdel.c,v <-- insdel.c new revision: 1.5; previous revision: 1.4 reuse log message of previous file? [yn](y): n enter log message, terminated with single '.' or end of file: >> * insdel.c: #include "intervals.h" (prepare_to_modify_buffer): Call verify_interval_modification(). (insert_from_string): Call offset_intervals() and graft_intervals_into_buffer(). (del_range): Call offset_intervals(). (insert): Call offset_interv>> >> >> >> >> als(). >> . done
author Joseph Arceneaux <jla@gnu.org>
date Thu, 01 Oct 1992 00:56:11 +0000
parents 3d1bf36f0896
children b74d9663f9a6
line wrap: on
line source

/* Fully extensible Emacs, running on Unix, intended for GNU.
   Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.

This file is part of GNU Emacs.

GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */


#include <signal.h>
#include <errno.h>

#include "config.h"
#include <stdio.h>

#include <sys/types.h>
#include <sys/file.h>

#ifdef VMS
#include <ssdef.h>
#endif

#ifdef BSD
#include <sys/ioctl.h>
#endif

#ifdef HAVE_TERMIOS
#include <termios.h>
#endif

#ifdef APOLLO
#ifndef APOLLO_SR10
#include <default_acl.h>
#endif
#endif

#include "lisp.h"
#include "commands.h"
#include "intervals.h"

#include "systty.h"

#ifndef O_RDWR
#define O_RDWR 2
#endif

#define PRIO_PROCESS 0

/* 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 initialized;

/* Variable whose value is symbol giving operating system type */
Lisp_Object Vsystem_type;
  
/* If non-zero, emacs should not attempt to use an window-specific code,
   but instead should use the virtual terminal under which it was started */
int inhibit_window_system;

/* If nonzero, set Emacs to run at this priority.  This is also used
   in child_setup and sys_suspend to make sure subshells run at normal
   priority; Those functions have their own extern declaration.  */
int emacs_priority;

#ifdef HAVE_X_WINDOWS
/* If non-zero, -d was specified, meaning we're using some window system. */
int display_arg;
#endif

/* An address near the bottom of the stack.
   Tells GC how to save a copy of the stack.  */
char *stack_bottom;

#ifdef HAVE_X_WINDOWS
extern Lisp_Object Vwindow_system;
#endif /* HAVE_X_WINDOWS */

#ifdef USG_SHARED_LIBRARIES
/* If nonzero, this is the place to put the end of the writable segment
   at startup.  */

unsigned int bss_end = 0;
#endif

/* Nonzero means running Emacs without interactive terminal.  */

int noninteractive;

/* Value of Lisp variable `noninteractive'.
   Normally same as C variable `noninteractive'
   but nothing terrible happens if user sets this one.  */

int noninteractive1;

/* Signal code for the fatal signal that was received */
int fatal_error_code;

/* Nonzero if handling a fatal error already */
int fatal_error_in_progress;

/* Handle bus errors, illegal instruction, etc. */
SIGTYPE
fatal_error_signal (sig)
     int sig;
{
  fatal_error_code = sig;
  signal (sig, SIG_DFL);

  /* If fatal error occurs in code below, avoid infinite recursion.  */
  if (fatal_error_in_progress)
    kill (getpid (), fatal_error_code);

  fatal_error_in_progress = 1;

  /* If we are controlling the terminal, reset terminal modes */
#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 */
  kill_buffer_processes (Qnil);
  Fdo_auto_save (Qt, Qnil);

#ifdef CLASH_DETECTION
  unlock_all_files ();
#endif /* CLASH_DETECTION */

#ifdef VMS
  kill_vms_processes ();
  LIB$STOP (SS$_ABORT);
#else
  /* Signal the same code; this time it will really be fatal.  */
  kill (getpid (), fatal_error_code);
#endif /* not VMS */
}

/* Code for dealing with Lisp access to the Unix command line */

static
init_cmdargs (argc, argv, skip_args)
     int argc;
     char **argv;
     int skip_args;
{
  register int i;

  Vcommand_line_args = Qnil;

  for (i = argc - 1; i >= 0; i--)
    {
      if (i == 0 || i > skip_args)
	Vcommand_line_args
	  = Fcons (build_string (argv[i]), Vcommand_line_args);
    }
}

#ifdef VMS
#ifdef LINK_CRTL_SHARE
#ifdef SHAREABLE_LIB_BUG
extern noshare char **environ;
#endif /* SHAREABLE_LIB_BUG */
#endif /* LINK_CRTL_SHARE */
#endif /* VMS */

/* We don't include crtbegin.o and crtend.o in the link,
   so these functions and variables might be missed.
   Provide dummy definitions to avoid error.
   (We don't have any real constructors or destructors.)  */
#ifdef __GNUC__
__do_global_ctors ()
{}
__do_global_ctors_aux ()
{}
__do_global_dtors ()
{}
char * __CTOR_LIST__[2] = { (char *) (-1), 0 };
char * __DTOR_LIST__[2] = { (char *) (-1), 0 };
__main ()
{}
#endif /* __GNUC__ */

/* ARGSUSED */
main (argc, argv, envp)
     int argc;
     char **argv;
     char **envp;
{
  char stack_bottom_variable;
  int skip_args = 0;
  extern int errno;
  extern sys_nerr;
  extern char *sys_errlist[];
  extern void malloc_warning ();

/* Map in shared memory, if we are using that.  */
#ifdef HAVE_SHM
  if (argc > 1 && !strcmp (argv[1], "-nl"))
    {
      map_in_data (0);
      /* The shared memory was just restored, which clobbered this.  */
      skip_args = 1;
    }
  else
    {
      map_in_data (1);
      /* The shared memory was just restored, which clobbered this.  */
      skip_args = 0;
    }
#endif

#ifdef HAVE_X_WINDOWS
  /* Stupid kludge to catch command-line display spec.  We can't
     handle this argument entirely in window system dependent code
     because we don't even know which window system dependent code
     to run until we've recognized this argument.  */
  {
    int i;

    for (i = 1; (i < argc && ! display_arg); i++)
      if (!strcmp (argv[i], "-d"))
	display_arg = 1;
  }
#endif

#ifdef VMS
  /* If -map specified, map the data file in */
  if (argc > 2 && ! strcmp (argv[1], "-map"))
    {
      skip_args = 2;
      mapin_data (argv[2]);
    }

#ifdef LINK_CRTL_SHARE
#ifdef SHAREABLE_LIB_BUG
  /* Bletcherous shared libraries! */
  if (!stdin)
    stdin = fdopen (0, "r");
  if (!stdout)
    stdout = fdopen (1, "w");
  if (!stderr)
    stderr = fdopen (2, "w");
  if (!environ)
    environ = envp;
#endif /* SHAREABLE_LIB_BUG */
#endif /* LINK_CRTL_SHARE */
#endif /* VMS */

  /* Record (approximately) where the stack begins.  */
  stack_bottom = &stack_bottom_variable;

#ifdef RUN_TIME_REMAP
  if (initialized)
    run_time_remap (argv[0]);
#endif

#ifdef USG_SHARED_LIBRARIES
  if (bss_end)
    brk (bss_end);
#endif

  clearerr (stdin);
#ifdef BSD
  setpgrp (0, getpid ());
#endif

#ifdef APOLLO
#ifndef APOLLO_SR10
  /* If USE_DOMAIN_ACLS environment variable exists,
     use ACLs rather than UNIX modes. */
  if (egetenv ("USE_DOMAIN_ACLS"))
    default_acl (USE_DEFACL);
#endif
#endif /* APOLLO */

#ifndef SYSTEM_MALLOC
  if (! initialized)
    malloc_init (0, malloc_warning);
#endif	/* not SYSTEM_MALLOC */

#ifdef PRIO_PROCESS
  if (emacs_priority)
    nice (emacs_priority);
  setuid (getuid ());
#endif /* PRIO_PROCESS */

#ifdef BSD
  /* interrupt_input has trouble if we aren't in a separate process group.  */
  setpgrp (getpid (), getpid ());
#endif

  inhibit_window_system = 0;

  /* Handle the -t switch, which specifies filename to use as terminal */
  if (skip_args + 2 < argc && !strcmp (argv[skip_args + 1], "-t"))
    {
      int result;
      skip_args += 2;
      close (0);
      close (1);
      result = open (argv[skip_args], O_RDWR, 2 );
      if (result < 0)
	{
	  char *errstring;

	  if (errno >= 0 && errno < sys_nerr)
	    errstring = sys_errlist[errno];
	  else
	    errstring = "undocumented error code";
	  fprintf (stderr, "emacs: %s: %s\n", argv[skip_args], errstring);
	  exit (1);
	}
      dup (0);
      if (! isatty (0))
	{
	  fprintf (stderr, "emacs: %s: not a tty\n", argv[skip_args]);
	  exit (1);
	}
      fprintf (stderr, "Using %s\n", argv[skip_args]);
#ifdef HAVE_X_WINDOWS
      inhibit_window_system = 1;	/* -t => -nw */
#endif
    }

  if (skip_args + 1 < argc
      && (!strcmp (argv[skip_args + 1], "-nw")))
    {
      skip_args += 1;
      inhibit_window_system = 1;
    }

/* Handle the -batch switch, which means don't do interactive display.  */
  noninteractive = 0;
  if (skip_args + 1 < argc && !strcmp (argv[skip_args + 1], "-batch"))
    {
      skip_args += 1;
      noninteractive = 1;
    }

#ifdef POSIX_SIGNALS
  init_signals ();
#endif

  if (
#ifndef CANNOT_DUMP
      ! noninteractive || initialized
#else
      1
#endif
      )
    {
      /* Don't catch these signals in batch mode if not initialized.
	 On some machines, this sets static data that would make
	 signal fail to work right when the dumped Emacs is run.  */
      signal (SIGHUP, fatal_error_signal);
      signal (SIGQUIT, fatal_error_signal);
      signal (SIGILL, fatal_error_signal);
      signal (SIGTRAP, fatal_error_signal);
      signal (SIGIOT, fatal_error_signal);
#ifdef SIGEMT
      signal (SIGEMT, fatal_error_signal);
#endif
      signal (SIGFPE, fatal_error_signal);
      signal (SIGBUS, fatal_error_signal);
      signal (SIGSEGV, fatal_error_signal);
      signal (SIGSYS, fatal_error_signal);
      signal (SIGTERM, fatal_error_signal);
#ifdef SIGXCPU
      signal (SIGXCPU, fatal_error_signal);
#endif
#ifdef SIGXFSZ
      signal (SIGXFSZ, fatal_error_signal);
#endif /* SIGXFSZ */

#ifdef AIX
      signal (SIGDANGER, fatal_error_signal);
      signal (20, fatal_error_signal);
      signal (21, fatal_error_signal);
      signal (22, fatal_error_signal);
      signal (23, fatal_error_signal);
      signal (24, fatal_error_signal);
#ifdef SIGIO
      signal (SIGAIO, fatal_error_signal);
      signal (SIGPTY, fatal_error_signal);
#endif
      signal (SIGIOINT, fatal_error_signal);
      signal (SIGGRANT, fatal_error_signal);
      signal (SIGRETRACT, fatal_error_signal);
      signal (SIGSOUND, fatal_error_signal);
      signal (SIGMSG, fatal_error_signal);
#endif /* AIX */
    }

  noninteractive1 = noninteractive;

/* Perform basic initializations (not merely interning symbols) */

  if (!initialized)
    {
      init_alloc_once ();
      init_obarray ();
      init_eval_once ();
      init_syntax_once ();	/* Create standard syntax table.  */
		      /* Must be done before init_buffer */
      init_casetab_once ();
      init_buffer_once ();	/* Create buffer table and some buffers */
      init_minibuf_once ();	/* Create list of minibuffers */
			      /* Must precede init_window_once */
      init_window_once ();	/* Init the window system */
    }

  init_alloc ();
  init_eval ();
  init_data ();
  init_lread ();

  init_cmdargs (argc, argv, skip_args);	/* Create list Vcommand_line_args */
  init_buffer ();	/* Init default directory of main buffer */
  if (!noninteractive)
    {
#ifdef VMS
      init_vms_input ();/* init_display calls get_frame_size, that needs this */
#endif /* VMS */
      init_display ();	/* Determine terminal type.  init_sys_modes uses results */
    }
  init_keyboard ();	/* This too must precede init_sys_modes */
  init_callproc ();	/* And this too. */
#ifdef VMS
  init_vmsproc ();	/* And this too. */
#endif /* VMS */
  init_sys_modes ();	/* Init system terminal modes (RAW or CBREAK, etc.) */
  init_xdisp ();
  init_macros ();
  init_editfns ();
#ifdef LISP_FLOAT_TYPE
  init_floatfns ();
#endif
#ifdef VMS
  init_vmsfns ();
#endif /* VMS */
  init_process ();
#ifdef CLASH_DETECTION
  init_filelock ();
#endif /* CLASH_DETECTION */

/* Intern the names of all standard functions and variables; define standard keys */

  if (!initialized)
    {
      /* The basic levels of Lisp must come first */
      /* And data must come first of all
	 for the sake of symbols like error-message */
      syms_of_data ();
      syms_of_alloc ();
      syms_of_lread ();
      syms_of_print ();
      syms_of_eval ();
      syms_of_fns ();
#ifdef LISP_FLOAT_TYPE
      syms_of_floatfns ();
#endif

      syms_of_abbrev ();
      syms_of_buffer ();
      syms_of_bytecode ();
      syms_of_callint ();
      syms_of_casefiddle ();
      syms_of_casetab ();
      syms_of_callproc ();
      syms_of_cmds ();
#ifndef NO_DIR_LIBRARY
      syms_of_dired ();
#endif /* not NO_DIR_LIBRARY */
      syms_of_display ();
      syms_of_doc ();
      syms_of_editfns ();
      syms_of_emacs ();
      syms_of_fileio ();
#ifdef CLASH_DETECTION
      syms_of_filelock ();
#endif /* CLASH_DETECTION */
      syms_of_indent ();
      syms_of_keyboard ();
      syms_of_keymap ();
      syms_of_macros ();
      syms_of_marker ();
      syms_of_minibuf ();
      syms_of_mocklisp ();
      syms_of_process ();
      syms_of_search ();
      syms_of_frame ();
      syms_of_syntax ();
      syms_of_undo ();

      /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
      syms_of_textprop ();
#ifdef VMS
      syms_of_vmsproc ();
#endif /* VMS */
      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_WINDOW
#ifndef NO_X_MENU
      syms_of_xmenu ();
#endif /* not NO_X_MENU */
#endif /* HAVE_X_MENU */
#endif /* HAVE_X_WINDOWS */

#ifdef SYMS_SYSTEM
      SYMS_SYSTEM;
#endif

#ifdef SYMS_MACHINE
      SYMS_MACHINE;
#endif

      keys_of_casefiddle ();
      keys_of_cmds ();
      keys_of_buffer ();
      keys_of_keyboard ();
      keys_of_keymap ();
      keys_of_macros ();
      keys_of_minibuf ();
      keys_of_window ();
    }

  if (!initialized)
    {
      /* Handle -l loadup-and-dump, args passed by Makefile. */
      if (argc > 2 + skip_args && !strcmp (argv[1 + skip_args], "-l"))
	Vtop_level = Fcons (intern ("load"),
			    Fcons (build_string (argv[2 + skip_args]), Qnil));
#ifdef CANNOT_DUMP
      /* Unless next switch is -nl, load "loadup.el" first thing.  */
      if (!(argc > 1 + skip_args && !strcmp (argv[1 + skip_args], "-nl")))
	Vtop_level = Fcons (intern ("load"),
			    Fcons (build_string ("loadup.el"), Qnil));
#endif /* CANNOT_DUMP */
    }

  initialized = 1;

#ifdef sun
  /* sun's localtime() has a bug.  it caches the value of the time
     zone rather than looking it up every time.  Since localtime() is
     called to bolt the undumping time into the undumped emacs, this
     results in localtime() ignoring the TZ environment variable.
     This flushes the new TZ value into localtime(). */
  tzset();
#endif /* sun */

  /* Enter editor command loop.  This never returns.  */
  Frecursive_edit ();
  /* NOTREACHED */
}

DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P",
  "Exit the Emacs job and kill it.\n\
If ARG is an integer, return ARG as the exit program code.\n\
If ARG is a  string, stuff it as keyboard input.\n\n\
The value of `kill-emacs-hook', if not void,\n\
is a list of functions (of no args),\n\
all of which are called before Emacs is actually killed.")
  (arg)
     Lisp_Object arg;
{
  Lisp_Object hook, hook1;
  int i;
  struct gcpro gcpro1;

  GCPRO1 (arg);

  if (feof (stdin))
    arg = Qt;

  if (!NILP (Vrun_hooks) && !noninteractive)
    call1 (Vrun_hooks, intern ("kill-emacs-hook"));

  kill_buffer_processes (Qnil);

#ifdef VMS
  kill_vms_processes ();
#endif /* VMS */

  Fdo_auto_save (Qt, Qnil);

#ifdef CLASH_DETECTION
  unlock_all_files ();
#endif /* CLASH_DETECTION */

  fflush (stdout);
  reset_sys_modes ();

#ifdef HAVE_X_WINDOWS
  if (!noninteractive && EQ (Vwindow_system, intern ("x")))
    Fx_close_current_connection ();
#endif /* HAVE_X_WINDOWS */

  UNGCPRO;

/* Is it really necessary to do this deassign
   when we are going to exit anyway?  */
/* #ifdef VMS
  stop_vms_input ();
 #endif  */
  stuff_buffered_input (arg);
#ifdef SIGIO
  /* There is a tendency for a SIGIO signal to arrive within exit,
     and cause a SIGHUP because the input descriptor is already closed.  */
  unrequest_sigio ();
  signal (SIGIO, SIG_IGN);
#endif
  exit ((XTYPE (arg) == Lisp_Int) ? XINT (arg)
#ifdef VMS
	: 1
#else
	: 0
#endif
	);
  /* NOTREACHED */
}

#ifndef CANNOT_DUMP
/* Nothing like this can be implemented on an Apollo.
   What a loss!  */

#ifdef HAVE_SHM

DEFUN ("dump-emacs-data", Fdump_emacs_data, Sdump_emacs_data, 1, 1, 0,
  "Dump current state of Emacs into data file FILENAME.\n\
This function exists on systems that use HAVE_SHM.")
  (intoname)
     Lisp_Object intoname;
{
  extern int my_edata;
  Lisp_Object tem;
  extern void malloc_warning ();

  CHECK_STRING (intoname, 0);
  intoname = Fexpand_file_name (intoname, Qnil);

  tem = Vpurify_flag;
  Vpurify_flag = Qnil;

  fflush (stdout);
  /* Tell malloc where start of impure now is */
  /* Also arrange for warnings when nearly out of space.  */
#ifndef SYSTEM_MALLOC
  malloc_init (&my_edata, malloc_warning);
#endif
  map_out_data (XSTRING (intoname)->data);

  Vpurify_flag = tem;

  return Qnil;
}

#else /* not HAVE_SHM */

DEFUN ("dump-emacs", Fdump_emacs, Sdump_emacs, 2, 2, 0,
  "Dump current state of Emacs into executable file FILENAME.\n\
Take symbols from SYMFILE (presumably the file you executed to run Emacs).\n\
This is used in the file `loadup.el' when building Emacs.\n\
\n\
Bind `command-line-processed' to nil before dumping,\n\
if you want the dumped Emacs to process its command line\n\
and announce itself normally when it is run.")
  (intoname, symname)
     Lisp_Object intoname, symname;
{
  extern int my_edata;
  Lisp_Object tem;
  extern void malloc_warning ();

  CHECK_STRING (intoname, 0);
  intoname = Fexpand_file_name (intoname, Qnil);
  if (!NILP (symname))
    {
      CHECK_STRING (symname, 0);
      if (XSTRING (symname)->size)
	symname = Fexpand_file_name (symname, Qnil);
    }

  tem = Vpurify_flag;
  Vpurify_flag = Qnil;

  fflush (stdout);
#ifdef VMS
  mapout_data (XSTRING (intoname)->data);
#else
  /* Tell malloc where start of impure now is */
  /* Also arrange for warnings when nearly out of space.  */
#ifndef SYSTEM_MALLOC
  malloc_init (&my_edata, malloc_warning);
#endif
  unexec (XSTRING (intoname)->data,
	  !NILP (symname) ? XSTRING (symname)->data : 0, &my_edata, 0, 0);
#endif /* not VMS */

  Vpurify_flag = tem;

  return Qnil;
}

#endif /* not HAVE_SHM */

#endif /* not CANNOT_DUMP */

#ifdef VMS
#define SEPCHAR ','
#else
#define SEPCHAR ':'
#endif

Lisp_Object
decode_env_path (evarname, defalt)
     char *evarname, *defalt;
{
  register char *path, *p;
  extern char *index ();

  Lisp_Object lpath;

  /* 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;
  while (1)
    {
      p = index (path, SEPCHAR);
      if (!p) p = path + strlen (path);
      lpath = Fcons (p - path ? make_string (path, p - path) : Qnil,
		     lpath);
      if (*p)
	path = p + 1;
      else
	break;
    }
  return Fnreverse (lpath);
}

syms_of_emacs ()
{
#ifdef HAVE_SHM
  defsubr (&Sdump_emacs_data);
#else
  defsubr (&Sdump_emacs);
#endif

  defsubr (&Skill_emacs);

  DEFVAR_LISP ("command-line-args", &Vcommand_line_args,
    "Args passed by shell to Emacs, as a list of strings.");

  DEFVAR_LISP ("system-type", &Vsystem_type,
    "Value is symbol indicating type of operating system you are using.");
  Vsystem_type = intern (SYSTEM_TYPE);

  DEFVAR_BOOL ("noninteractive", &noninteractive1,
    "Non-nil means Emacs is running without interactive terminal.");

  DEFVAR_LISP ("kill-emacs-hook", &Vkill_emacs_hook,
    "Hook to be run whenever kill-emacs is called.\n\
Since kill-emacs may be invoked when the terminal is disconnected (or\n\
in other similar situations), functions placed on this hook should not\n\
not expect to be able to interact with the user.");
  Vkill_emacs_hook = Qnil;

  DEFVAR_INT ("emacs-priority", &emacs_priority,
    "Priority for Emacs to run at.\n\
This value is effective only if set before Emacs is dumped,\n\
and only if the Emacs executable is installed with setuid to permit\n\
it to change priority.  (Emacs sets its uid back to the real uid.)");
  emacs_priority = 0;
}