RE: FVWM: Problems with FvwmButtons

From: Grant McDorman <grant_at_isgtec.com>
Date: Thu, 31 Oct 1996 09:24:58 -0500 (EST)

-----BEGIN PGP SIGNED MESSAGE-----


On 31-Oct-96 15:41:36 Jonathan Nicholson wrote:
> > Has anybody else had this problem, when logging out of an X session,
> running Fvwm, the FvwmButtons module fails to exit and goes into a race
> condition, taking all the available CPU.
>
> The platform I am running fvwm on is a Digital Alpha 255/233Mhz with
> Digital Unix Version 4 & FVWM version 2.0.43
>
> Is this a known problem?

Yep. I posted a patch for it a while ago. Here it is; I'm also including
a similar patch for fvwm itself.


Grant McDorman <grant_at_isgtec.com>
ISG Technologies, Inc. http://www.isgtec.com
Mississauga, Ontario, Canada


-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQBVAwUBMni3f0Dmya2cFZ8ZAQHc1gH+LKbTl8cyHBYJpY6oLJoNuQ/rcISeeb8k
j4Vnwia5eYXUkBfTfM8FPe4hpD6H67q4TnWk2y5j+H1pc7XHrxotFw==
=SsvI
-----END PGP SIGNATURE-----


*** fvwm-2.0.43/modules/FvwmButtons/FvwmButtons.c.orig Thu Jun 27 10:45:30 1996
--- fvwm-2.0.43/modules/FvwmButtons/FvwmButtons.c Wed Sep 11 10:31:58 1996
***************
*** 27,32 ****
--- 27,33 ----
  #include <string.h>
  #include <sys/wait.h>
  #include <sys/time.h>
+ #include <sys/stat.h>
  #if defined ___AIX || defined _AIX || defined __QNX__ || defined ___AIXV3 || d
efined AIXV3 || defined _SEQUENT_
  #include <sys/select.h>
  #endif
***************
*** 75,80 ****
--- 76,82 ----
  /* ------------------------------ prototypes ------------------------------- *
/
  
  void DeadPipe(int nonsense);
+ void CleanUp(void);
  void SetButtonSize(button_info*,int,int);
  /* main */
  void Loop(void);
***************
*** 123,128 ****
--- 125,132 ----
  GC NormalGC;
  int Width,Height;
  
+ int running = 1;
+
  int x= -30000,y= -30000,w= -1,h= -1,gravity = NorthWestGravity;
  int new_desk = 0;
  int ready = 0;
***************
*** 170,182 ****
  **/
  void DeadPipe(int whatever)
  {
    button_info *b,*ub=UberButton;
    int button=-1;
  
- signal(SIGPIPE, SIG_IGN);/* Xsync may cause SIGPIPE */
-
    XSync(Dpy,0); /* Wait for thing to settle down a bit */
    XGrabServer(Dpy); /* We don't want interference right now */
    while(NextButton(&ub,&b,&button,0))
      {
        /* delete swallowed windows */
--- 174,217 ----
  **/
  void DeadPipe(int whatever)
  {
+ struct stat buf;
+
+ /*
+ * If a SIGPIPE arrives during this operation, just exit.
+ * - the signal will probably because the server is shutting
+ * down. Attempting to do any further processing is useless
+ * and may in fact, on some platforms, put the process into
+ * a tight loop (if SIGPIPE is ignored).
+ * 22 July 1996 GRM.
+ *
+ * Further investigation: XSync may loop *without* causing a SIGPIPE.
+ * This may be because the connection is dead, or because of the
+ * fact that X operations in signal handlers are discouraged.
+ *
+ * In order to cover all the bases, then, this function will now
+ * set a global flag which will cause the main loop to stop.
+ *
+ * SIGPIPE is reset to DeadPipe, as well.
+ */
+ signal(SIGPIPE, DeadPipe);
+
+ /*
+ * Try to check status of X connection.
+ */
+ if (fstat(XConnectionNumber(Dpy), &buf) == -1)
+ exit(0);
+
+ running = 0;
+ }
+
+ void CleanUp(void)
+ {
    button_info *b,*ub=UberButton;
    int button=-1;
  
    XSync(Dpy,0); /* Wait for thing to settle down a bit */
    XGrabServer(Dpy); /* We don't want interference right now */
+
    while(NextButton(&ub,&b,&button,0))
      {
        /* delete swallowed windows */
***************
*** 506,512 ****
    int ex=10000,ey=10000,ex2=0,ey2=0;
  #endif
  
! while(1)
      {
        if(My_XNextEvent(Dpy,&Event))
          {
--- 541,547 ----
    int ex=10000,ey=10000,ex2=0,ey2=0;
  #endif
  
! while(running)
      {
        if(My_XNextEvent(Dpy,&Event))
          {
***************
*** 733,738 ****
--- 768,774 ----
            }
        }
      }
+ CleanUp();
  }
  
  /**
*** fvwm-2.0.43/fvwm/fvwm.c.orig Thu Jun 27 10:08:08 1996
--- fvwm-2.0.43/fvwm/fvwm.c Wed Sep 11 09:25:16 1996
***************
*** 1146,1152 ****
    /* No action is taken because usually this action is caused by someone
       using "xlogout" to be able to switch between multiple window managers
       */
! Done(0, NULL);
  }
  
  /***********************************************************************
--- 1146,1153 ----
    /* No action is taken because usually this action is caused by someone
       using "xlogout" to be able to switch between multiple window managers
       */
! ClosePipes();
! exit(1);
  }
  
  /***********************************************************************

End of MIME message
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Thu Oct 31 1996 - 08:31:26 GMT

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:59 BST