[gnu.emacs.bug] ``emacs -t /'' dumps core

eggert@burns.twinsun.com (Paul Eggert) (08/10/89)

The command ``emacs -t /'' dumps core, using GNU Emacs 18.54 running under
SunOS 4.0.1 on a Sun-3/50.  ``emacs -t X'' also dumps core for most other
values of X.  Here is a scenario.

	% emacs -t /
	Using /
	Abort (core dumped)
	% adb /local/bin/emacs
	:r -t /
	Using /
	SIGIOT 6: abort
	stopped	at	_kill+6:		bcss	_getpgrp+0xa
	$c
	_kill(?)
	_abort() + 6
	_wait_reading_process_input(0x0,0xffffffff,0x1)	+ 17c
	_kbd_buffer_get_char() + 70
	_get_char(0x1) + 1ea
	_read_key_sequence(0xefffadc,0x1e,0x0,0x0) + 5e
	_command_loop_1() + 108
	_internal_condition_case(0x12dcc,0x10ff8fc,0x129ea) + a8
	_command_loop_2(0x10ff80c) + 12
	_internal_catch(0x10ff8e8,0x12cac,0x10ff80c) + 6a
	_command_loop()	+ 50
	_Frecursive_edit() + 96
	_main(0x3,0xefffda8,0xefffdb8) + 4b0
	_start1() + 38
	__start() + 4


Here is a patch to src/emacs.c; it may mask a deeper bug in
wait_reading_process_input().  By the way, I think the third argument ``2'' in
``open(..., O_RDWR, 2)'' is a typographical error and should be removed, but I
preserved it because it does not cause a bug.


RCS file: RCS/emacs.c,v
retrieving revision 1.1
diff -c -r1.1 emacs.c
*** /tmp/,RCSt1a01670	Wed Aug  9 21:26:14 1989
--- emacs.c	Wed Aug  9 20:42:03 1989
***************
*** 237,244 ****
        skip_args += 2;
        close (0);
        close (1);
!       open (argv[skip_args], O_RDWR, 2 );
!       dup (0);
        fprintf (stderr, "Using %s\n", argv[skip_args]);
  #ifdef HAVE_X_WINDOWS
        inhibit_window_system = 1;	/* -t => -nw */
--- 237,244 ----
        skip_args += 2;
        close (0);
        close (1);
!       if (open (argv[skip_args],O_RDWR,2) != 0 || !isatty (0) || dup (0) != 1)
! 	fatal ("%s: bad device\n", argv[skip_args]);
        fprintf (stderr, "Using %s\n", argv[skip_args]);
  #ifdef HAVE_X_WINDOWS
        inhibit_window_system = 1;	/* -t => -nw */