emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 2c1b860: Don't freeze with unreadable processes


From: Paul Eggert
Subject: [Emacs-diffs] master 2c1b860: Don't freeze with unreadable processes
Date: Sat, 25 Apr 2015 23:17:59 +0000

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

    Don't freeze with unreadable processes
    
    Don't freeze if an exiting process can't be read from. (Bug#19860).
    This fixes a bug I introduced in
    2014-07-08T07:24:address@hidden@cs.ucla.edu
    "* process.c: Add sanity checks for file descriptors."
    Dmitry Gutov did most of the legwork in finding the problem.
    * src/process.c (wait_reading_process_output):
    Treat non-running processes that can't be read from
    the same as other non-running processes.
---
 src/process.c |   40 ++++++++++++++++++++++------------------
 1 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/src/process.c b/src/process.c
index c745507..3e04cb7 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4785,37 +4785,41 @@ wait_reading_process_output (intmax_t time_limit, int 
nsecs, int read_kbd,
       if (wait_proc && wait_proc->raw_status_new)
        update_status (wait_proc);
       if (wait_proc
-         && wait_proc->infd >= 0
          && ! EQ (wait_proc->status, Qrun)
          && ! EQ (wait_proc->status, Qconnect))
        {
          bool read_some_bytes = false;
 
          clear_waiting_for_input ();
-         XSETPROCESS (proc, wait_proc);
 
-         /* Read data from the process, until we exhaust it.  */
-         while (true)
+         /* If data can be read from the process, do so until exhausted.  */
+         if (wait_proc->infd >= 0)
            {
-             int nread = read_process_output (proc, wait_proc->infd);
-             if (nread < 0)
+             XSETPROCESS (proc, wait_proc);
+
+             while (true)
                {
-                 if (errno == EIO || errno == EAGAIN)
-                   break;
+                 int nread = read_process_output (proc, wait_proc->infd);
+                 if (nread < 0)
+                   {
+                   if (errno == EIO || errno == EAGAIN)
+                     break;
 #ifdef EWOULDBLOCK
-                 if (errno == EWOULDBLOCK)
-                   break;
+                   if (errno == EWOULDBLOCK)
+                     break;
 #endif
-               }
-             else
-               {
-                 if (got_some_input < nread)
-                   got_some_input = nread;
-                 if (nread == 0)
-                   break;
-                 read_some_bytes = true;
+                   }
+                 else
+                   {
+                     if (got_some_input < nread)
+                       got_some_input = nread;
+                     if (nread == 0)
+                       break;
+                     read_some_bytes = true;
+                   }
                }
            }
+
          if (read_some_bytes && do_display)
            redisplay_preserve_echo_area (10);
 



reply via email to

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