emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master e1c6b40e9d: Fix input availability detection during visible-b


From: Robert Pluim
Subject: Re: master e1c6b40e9d: Fix input availability detection during visible-bell
Date: Thu, 21 Apr 2022 17:26:11 +0200

>>>>> On Wed, 13 Apr 2022 03:05:08 -0400 (EDT), Po Lu via Mailing list for 
>>>>> Emacs changes <emacs-diffs@gnu.org> said:
 
    Po> +      /* Wait for some input to become available on the X
    Po> +        connection.  */
    Po> +      FD_ZERO (&fds);
    Po> +      FD_SET (fd, &fds);
    Po> +
    Po>        /* Try to wait that long--but we might wake up sooner.  */
    Po> -      pselect (0, NULL, NULL, NULL, &timeout, NULL);
    Po> +      pselect (fd + 1, &fds, NULL, NULL, &timeout, NULL);
    Po> +
    Po> +      /* Some input is available, exit the visible bell.  */
    Po> +      if (FD_ISSET (fd, &fds))
    Po> +       break;

Strictly speaking youʼre only allowed to check if fd is set in fds if
pselect didnʼt fail, so you should be doing something like this (Iʼve
lost track of whether weʼre allowed to use C99's variable definition
rules now).

diff --git a/src/xterm.c b/src/xterm.c
index 69e9302973..be4d35a62d 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8884,12 +8884,13 @@ XTflash (struct frame *f)
         connection.  */
       FD_ZERO (&fds);
       FD_SET (fd, &fds);
+      int rc;
 
       /* Try to wait that long--but we might wake up sooner.  */
-      pselect (fd + 1, &fds, NULL, NULL, &timeout, NULL);
+      rc = pselect (fd + 1, &fds, NULL, NULL, &timeout, NULL);
 
       /* Some input is available, exit the visible bell.  */
-      if (FD_ISSET (fd, &fds))
+      if (rc > 0 && FD_ISSET (fd, &fds))
        break;
     }
 


Robert
-- 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]