Xref: utzoo comp.emacs:8396 gnu.emacs:2942 comp.unix.i386:5506 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!nuug!ifi!barsoom!tih From: tih@barsoom.nhh.no (Tom Ivar Helbekkmo) Newsgroups: comp.emacs,gnu.emacs,comp.unix.i386 Subject: Re: GNUemacs Murder-Suicide under BASH Keywords: GNU emacs bash fatal error Message-ID: <890@barsoom.nhh.no> Date: 1 Jun 90 07:46:20 GMT References: <1990May26.054523.19453@rancho.uucp> <1990May31.225005.14779@diku.dk> Followup-To: comp.emacs Organization: Norwegian School of Economics Lines: 132 OK, since there's been several postings about this since we posted our fix to gnu.bug.bash, here's a repost. This will fix the bash/emacs ^G problem for SCO Unix V/386 at least... Bash version number: 1.05 with the March 11th patches. Hardware: Trident 386 (25Mhz/8Mb/330Mb) Operating system: SCO Unix V/386 3.2.0 Compiler: GCC 1.37.1 Description: Coredump in "history", signal fumbling kills shell. Reproduction: Type "history", or start EMACS and say ^G^G. A friend of mine and myself have just gotten bash up and running under SCO Unix V/386 (don't laugh!), and we've had to change a couple of things to make it work under this environment. We believe the changes that were necessary constitute real bugs in bash, so I'm describing them here... Sorry about this not being in patch format -- but I figure you'd like to study it before doing anything with it anyway, so... :-) One of them is in the patches that came out the other day... In the history patch, you say (my arrowed comments): } } <--- This should be... + if (strcmp (list->word->word, "-s") == 0) + { + extern int history_expand (); + char *expanded; + int rval; + + list = list->next; + + while (list) + { + rval = history_expand (list->word->word, &expanded); + printf ("%s", expanded); + fflush (stdout); + + if (rval == -1) + return (EXECUTION_FAILURE); + + free (expanded); + + list = list->next; + } + } + <--- ...here! limit = get_numeric_arg (list); if (limit < 0) limit = -limit; ...which is wrong, since the curly brace my first arrow points to should be where the second arrow is. This makes the "history" builtin coredump the shell, which is hardly what one wants... :-) Other fixes that were needed have to do with signal handling. It doesn't show up so easily, but with GNU EMACS we discovered that the editor would go "Fatal error. (1)" the *second* time Ctrl-G was hit during an editing session. It turned out that bash got confused over the signals that EMACS uses for Ctrl-G aborts. First, nojobs.c. Here's how our file now looks at the point where signals are first initialized: initialize_job_signals () { extern int login_shell; #ifdef notdef extern sighandler throw_to_top_level (); signal (SIGINT, throw_to_top_level); #else extern sighandler sigint_sighandler (); signal (SIGINT, sigint_sighandler); #endif signal (SIGQUIT, SIG_IGN); Then there's shell.c. Same stuff going on, here's what our sigint_sighandler looks like (we've inserted the re-trapping of the signal at the start of the function, and declared the parameter sig for it to use: sighandler sigint_sighandler (sig) int sig; { signal(sig, sigint_sighandler); if (interrupt_immediately) { interrupt_immediately = 0; throw_to_top_level (); } if (!interrupt_state) interrupt_state++; } Finally, a fix is needed in parse.y. Still the same problem, this is just part of the corrections above. We change a declaration and a call to use sigint_sighandler: yy_readline_get () { if (!current_readline_line) { char *readline (); SigHandler *old_sigint; #ifdef notdef extern sighandler throw_to_top_level (); #else extern sighandler sigint_sighandler (); #endif if (!readline_initialized_yet) { initialize_readline (); readline_initialized_yet = 1; } #ifdef notdef old_sigint = (SigHandler *)signal (SIGINT, throw_to_top_level); #else old_sigint = (SigHandler *)signal (SIGINT, sigint_sighandler); #endif -tih -- Tom Ivar Helbekkmo, NHH, Bergen, Norway. Telephone: +47-5-959205 tih@barsoom.nhh.no, thelbekk@norunit.bitnet, edb_tom@debet.nhh.no -- Tom Ivar Helbekkmo, NHH, Bergen, Norway. Telephone: +47-5-959205 tih@barsoom.nhh.no, thelbekk@norunit.bitnet, edb_tom@debet.nhh.no