GNUemacs Murder-Suicide under BASH

Tom Ivar Helbekkmo tih at barsoom.nhh.no
Fri Jun 1 17:46:20 AEST 1990


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 at barsoom.nhh.no, thelbekk at norunit.bitnet, edb_tom at debet.nhh.no
-- 
Tom Ivar Helbekkmo, NHH, Bergen, Norway.  Telephone: +47-5-959205
tih at barsoom.nhh.no, thelbekk at norunit.bitnet, edb_tom at debet.nhh.no



More information about the Comp.unix.i386 mailing list