Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CCA Emacs subshells

2 views
Skip to first unread message

Joseph Chapman

unread,
Dec 26, 1984, 10:48:44 AM12/26/84
to
<>

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. j...@cca-unix.ARPA
20 William St.
Wellesley, MA 02181 (617) 235-2600

Steve Zimmerman

unread,
Dec 31, 1984, 9:54:03 AM12/31/84
to
> 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

0 new messages