emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 2f98597 2/3: Fix emacsclient hang when backgrounded


From: Paul Eggert
Subject: [Emacs-diffs] master 2f98597 2/3: Fix emacsclient hang when backgrounded
Date: Thu, 6 Dec 2018 13:48:11 -0500 (EST)

branch: master
commit 2f985977f691a37a6d45298128b88d0cefcc93a1
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Fix emacsclient hang when backgrounded
    
    Problem reported by Kaushal Modi in:
    https://lists.gnu.org/r/emacs-devel/2018-12/msg00083.html
    The tcdrain call replaced an fdatasync call which had no
    effect on the tty, so removing it entirely shouldn’t cause
    problems.  The fdatasync call replaced an fsync call which
    also had no effect on the tty, and the fsync call seems to be
    badly-merged revenant of emacsclient’s old (circa 2004) way of
    communicating to and from Emacs via FILE * streams, where
    fsync was apparently needed when talking to sockets.
    * lib-src/emacsclient.c [!DOS_NT]: Don’t include termios.h.
    (flush_stdout): Remove.  All callers removed.
    (main): Do not drain the tty after "Waiting for Emacs..."
    message.  There should be no need to drain, and draining it
    might send us a SIGTTOU.  Do not fflush stdout just before
    exiting, as exiting does that for us.
---
 lib-src/emacsclient.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 7de3665..653ab95 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -66,10 +66,6 @@ char *w32_getenv (const char *);
 
 #endif /* !WINDOWSNT */
 
-#ifndef DOS_NT
-# include <termios.h>
-#endif
-
 #include <ctype.h>
 #include <errno.h>
 #include <getopt.h>
@@ -1740,15 +1736,6 @@ start_daemon_and_retry_set_socket (void)
   return emacs_socket;
 }
 
-/* Flush standard output and its underlying file descriptor.  */
-static void
-flush_stdout (HSOCKET emacs_socket)
-{
-  fflush (stdout);
-  while (tcdrain (STDOUT_FILENO) != 0 && errno == EINTR)
-    act_on_signals (emacs_socket);
-}
-
 int
 main (int argc, char **argv)
 {
@@ -1964,7 +1951,7 @@ main (int argc, char **argv)
       printf ("Waiting for Emacs...");
       skiplf = false;
     }
-  flush_stdout (emacs_socket);
+  fflush (stdout);
 
   /* Now, wait for an answer and print any messages.  */
   while (exit_status == EXIT_SUCCESS)
@@ -2067,7 +2054,6 @@ main (int argc, char **argv)
 
   if (!skiplf)
     printf ("\n");
-  flush_stdout (emacs_socket);
 
   if (rl < 0)
     exit_status = EXIT_FAILURE;



reply via email to

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