[net.emacs] CCA Emacs subshells

bruce@godot.UUCP (Bruce Nemnich) (12/21/84)

There is a CCA emacs subshell termination bug.  If you start up a
subshell in a buffer through a pipe and the shell terminates, it prints
a "Broken Pipe" message and hangs emacs.

A more desired bahaviour would be to announce that the shell terminated
and kill the buffer (and window if in multi-window mode).

Repeat by starting up a csh buffer through a pipe and type "exit" to it.
You will lose.

On a previous subject, I have no problems running a franz lisp from a
subshell buffer.  I was just doing it a minute ago.  What problems are
you having?
-- 
--Bruce Nemnich, Thinking Machines Corporation, Cambridge, MA
  ihnp4!godot!bruce, bjn@mit-mc.arpa ... soon to be bruce@godot.arpa

joe@cca.UUCP (Joseph Chapman) (12/26/84)

<>

Here is a bug fix which solves the problem of a buffer shell in CCA
Emacs hanging the terminal when exited.  The problem was that Emacs was
hanging around forever trying to successfully read a stream which had
disappeared (second part of the fix below).  I also stumbled upon a
nasty infinite loop possibility in fflush; the function error() calls
getchar(), and if the latter encounters an error while doing its stuff
it calls error() and getchar() and so forth.  The terminal bell rings so
many times you want to put your fist through the screen.  Anyway, that's
the reason for the first part of the fix below.

*** e_io.c~	
--- e_io.c
***************
*** 813,821
  				(void) error(WARN, errno, "DCL mailbox");
  		} else
  #endif
! 		if (write(p->_file, p->_buf, p->_cnt) != p->_cnt)
! 			if (p != stdout && errno != 32)
! 				(void) error(WARN, errno, "fflush");
  		p->_cnt = 0;
  	}
  }

--- 813,819 -----
  				(void) error(WARN, errno, "DCL mailbox");
  		} else
  #endif
! 		write(p->_file, p->_buf, p->_cnt);
  		p->_cnt = 0;
  	}
  }
***************
*** 841,847
  		p->_buf[p->_cnt] = '\0';
  	} else
  #endif
! 		while((p->_cnt = read(p->_file, p->_buf, BSIZE)) < 0);
  	p->_skpos += p->_cnt;
  	p->_ptr = p->_buf + 1;
  	if (p->_cnt > 0) {

--- 839,848 -----
  		p->_buf[p->_cnt] = '\0';
  	} else
  #endif
! 		while((p->_cnt = read(p->_file, p->_buf, BSIZE)) < 0) {
!                         if (errno)
!                                 return (EOF);
!                 } 
  	p->_skpos += p->_cnt;
  	p->_ptr = p->_buf + 1;
  	if (p->_cnt > 0) {
  
-- Joseph Chapman                  decvax!cca!joe
   CCA Uniworks, Inc.              joe@cca-unix.ARPA
   20 William St.
   Wellesley, MA  02181            (617) 235-2600

z@masscomp.UUCP (Steve Zimmerman) (12/31/84)

> I also stumbled upon a
> nasty infinite loop possibility in fflush; the function error() calls
> getchar(), and if the latter encounters an error while doing its stuff
> it calls error() and getchar() and so forth.  The terminal bell rings so
> many times you want to put your fist through the screen.  Anyway, that's
> the reason for the first part of the fix below.

Under normal circumstances, the infinite loop you describe should never
happen.  If this really is a problem, then some code should be put in
getchar() so that it doesn't call error() if it is being invoked by
error().  But the fix that was posted is definitely the wrong thing to
do.  The call to error() in fflush is important, as there are a number
of legitimate reasons for the write to fail, and the user needs to be
notified about them.  For example, if the disk fills up, the old code
would warn the user with a message telling him exactly what happened.
The code represented by the fix would be silent, and the user would get
the disastrously mistaken impression that his file was written
correctly.  For these reasons, I strongly recommend against installing
the first part of the fix that was posted.

	Steve Zimmerman