This problem has existed for quite some time, and exists in both 
21.1p14 and 21.4p8.  I run a lot of remote xemacsen via ssh (ssh
tunnelling X: "ssh -n host xemacs &".)  When the displaying machine
reboots, or X dies, or the network goes away, the remote xemacs very
often (but not always) stays running, consuming lots of cpu.  For
example, right now one of my machine's load is >4 because:
  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME COMMAND
 7261 jwz       25   0 22544  22M  5196 R    29.1  4.3 296:35 xemacs
27487 jwz       25   0 23652  23M  5304 R    22.3  4.6 297:40 xemacs
 1078 jwz       23   0 22340  19M  4972 R    18.4  3.7  1130m xemacs
None of those xemacsen should still be alive.
I can't really tell where they are looping: when I attach and do
"finish" from select, it doesn't come out.  I guess either this
is gdb malfunctioning, or there is some signal handler lossage
going on.  Because as you see above, the %CPU is enormous.
    ...
    (no debugging symbols found)...
    Attaching to program: /usr/bin/xemacs-21.4.8, process 1078
    (gdb) bt
    #0  0x420d3b2e in select () from /lib/i686/libc.so.6
    #1  0x404118d0 in vendorShellWidgetClass () from /usr/X11R6/lib/libXt.so.6
    #2  0x403e7318 in _XtWaitForSomething () from /usr/X11R6/lib/libXt.so.6
    #3  0x403e8973 in XtAppPending () from /usr/X11R6/lib/libXt.so.6
    #4  0x0819dc3d in drain_X_queue ()
    #5  0x0819dcd4 in emacs_Xt_event_pending_p ()
    #6  0x080f8608 in event_stream_event_pending_p ()
    #7  0x080f9112 in detect_input_pending ()
    #8  0x080fa338 in run_pre_idle_hook ()
    #9  0x080fa872 in Fnext_event ()
    #10 0x0809b5f5 in Fcommand_loop_1 ()
    #11 0x080b4762 in condition_case_1 ()
    #12 0x0809b08a in command_loop_3 ()
    #13 0x0809b0bb in command_loop_2 ()
    #14 0x080b43b9 in internal_catch ()
    #15 0x0809b217 in initial_command_loop ()
    #16 0x080b0ca2 in xemacs_21_4_8_i386_redhat_linux ()
    #17 0x080b1732 in main ()
    #18 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6
    (gdb) quit
    The program is running.  Quit anyway (and detach it)? (y or n) y
    Detaching from program: /usr/bin/xemacs-21.4.8, process 1078
    ...
    Attaching to program: /usr/bin/xemacs-21.4.8, process 7261
    0x403e6bef in XtChangeManagedSet () from /usr/X11R6/lib/libXt.so.6
    (gdb) bt
    #0  0x403e6bef in XtChangeManagedSet () from /usr/X11R6/lib/libXt.so.6
    #1  0x403e71c3 in _XtWaitForSomething () from /usr/X11R6/lib/libXt.so.6
    #2  0x403e8973 in XtAppPending () from /usr/X11R6/lib/libXt.so.6
    #3  0x0819dc3d in drain_X_queue ()
    #4  0x0819dcd4 in emacs_Xt_event_pending_p ()
    #5  0x080f8608 in event_stream_event_pending_p ()
    #6  0x080f9112 in detect_input_pending ()
    #7  0x0816900b in redisplay_device ()
    #8  0x081692a7 in redisplay_without_hooks ()
    #9  0x080fa877 in Fnext_event ()
    #10 0x0809b5f5 in Fcommand_loop_1 ()
    #11 0x080b4762 in condition_case_1 ()
    #12 0x0809b08a in command_loop_3 ()
    #13 0x0809b0bb in command_loop_2 ()
    #14 0x080b43b9 in internal_catch ()
    #15 0x0809b217 in initial_command_loop ()
    #16 0x080b0ca2 in xemacs_21_4_8_i386_redhat_linux ()
    #17 0x080b1732 in main ()
    #18 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6
    (gdb) quit
    The program is running.  Quit anyway (and detach it)? (y or n) y
    Detaching from program: /usr/bin/xemacs-21.4.8, process 7261
    ...
    (no debugging symbols found)...
    Attaching to program: /usr/bin/xemacs-21.4.8, process 27487
    (gdb) bt
    #0  0x403e6cf8 in XtChangeManagedSet () from /usr/X11R6/lib/libXt.so.6
    #1  0x403e71c3 in _XtWaitForSomething () from /usr/X11R6/lib/libXt.so.6
    #2  0x403e8973 in XtAppPending () from /usr/X11R6/lib/libXt.so.6
    #3  0x0819dc3d in drain_X_queue ()
    #4  0x0819dcd4 in emacs_Xt_event_pending_p ()
    #5  0x080f8608 in event_stream_event_pending_p ()
    #6  0x080f9112 in detect_input_pending ()
    #7  0x0816900b in redisplay_device ()
    #8  0x081692a7 in redisplay_without_hooks ()
    #9  0x080fa877 in Fnext_event ()
    #10 0x0809b5f5 in Fcommand_loop_1 ()
    #11 0x080b4762 in condition_case_1 ()
    #12 0x0809b08a in command_loop_3 ()
    #13 0x0809b0bb in command_loop_2 ()
    #14 0x080b43b9 in internal_catch ()
    #15 0x0809b217 in initial_command_loop ()
    #16 0x080b0ca2 in xemacs_21_4_8_i386_redhat_linux ()
    #17 0x080b1732 in main ()
    #18 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6
    (gdb) quit
    The program is running.  Quit anyway (and detach it)? (y or n) y
    Detaching from program: /usr/bin/xemacs-21.4.8, process 27487
rpm -q xemacs: xemacs-21.4.8-16
Linux 2.4.18-14 #1 Wed Sep 4 12:13:11 EDT 2002 i686 athlon i386 GNU/Linux
Red Hat Linux release 8.0 (Psyche)
-- 
Jamie Zawinski
jwz(a)jwz.org             
http://www.jwz.org/
jwz(a)dnalounge.com       
http://www.dnalounge.com/