Subject: Re: bug#4970: 23.1; Emacs Gtk running nuts

From: Dan Nicolaescu <[email-masked]>
Date: Fri, 20 Nov 2009 01:11:19 -0800 (PST)

Jan Djärv <[email-masked]> writes:

  > Dan Nicolaescu skrev:
  > > Werner Fink <[email-masked]> writes:
  > >
  > >   > A user runs "emacs -nw" within xterm, and often stop them with CTRL-Z to
  > >   > keep them in background. Now Emacs loops and hogs both memory and cpu after
  > >   > shutting down X11 going to runlevel 3. Likely this was a leftover emacs from
  > >   > background.
  > >   >   > From top:
  > >   >   >   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+
  > > COMMAND              > 23902 xxxxxx    20   0 7222m 3.4g  608 R  100
  > > 88.9  59:28.72 emacs-gtk
  > >
  > > I have seen this in the past, but only with the info above I was able to
  > > find a reliable way to reproduce this.  
  > >
  > > It also happens with the lucid toolkit, so it's not related to gtk.
  > >
  > >
  > > Xnest :1&
  > > xterm -display :1
  > >
  > > Now in that xterm window in Xnest do:
  > > emacs -Q -nw
  > > C-z
  > >
  > > kill the Xnest window
  > >
  > > and watch the emacs process grow in size.
  > >
  > 
  > What happens is that reading from the terminal fails and Emacs tries
  > to remove that terminal, but in term.c:
  > 
  >   if (last_terminal)
  >       error ("Attempt to delete the sole terminal device with live frames");
  > 
  > 
  > which goes back to the command loop, tries to read agan, fails, and
  > tries to delete the terminal again, and so on.
  > 
  > If you remove this check, Emacs exits.  But I suppose it is there for
  > a reason, but I don't know what.  Anybody?

It's there so that if you do:
emacs -Q -nw
C-x 5 0
does not exit emacs.