raster pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=60d1c6d05c85d6af9448e0110218bb5a7e550b4b

commit 60d1c6d05c85d6af9448e0110218bb5a7e550b4b
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Tue Dec 13 11:53:50 2016 +0900

    term pty fd - properly shut down without a 100% cpu hang
    
    i've noticed that the exe cb tries to drain the pty fd but reads
    return -1 with EAGAIN so terminology just spins forever in cpu trying
    to drain a buffer that does not drain, so make a special case on exe
    exit - drain until there just is nothing else to read then give up.
    
    @fix
---
 src/bin/termpty.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 4c9330d..80e2939 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -157,9 +157,8 @@ _pty_size(Termpty *ty)
 }
 
 static Eina_Bool
-_cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler)
+_fd_read_do(Termpty *ty, Ecore_Fd_Handler *fd_handler, Eina_Bool 
false_on_empty)
 {
-   Termpty *ty = data;
    char buf[4097];
    Eina_Unicode codepoint[4097];
    int len, i, j, k, reads;
@@ -286,11 +285,17 @@ _cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler)
         return ECORE_CALLBACK_CANCEL;
      }
 #endif
-
+   if ((false_on_empty) && (len <= 0)) return ECORE_CALLBACK_CANCEL;
    return EINA_TRUE;
 }
 
 static Eina_Bool
+_cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler)
+{
+   return _fd_read_do(data, fd_handler, EINA_FALSE);
+}
+
+static Eina_Bool
 _cb_exe_exit(void *data,
              int _type EINA_UNUSED,
              void *event)
@@ -311,7 +316,7 @@ _cb_exe_exit(void *data,
    res = ECORE_CALLBACK_PASS_ON;
    while (ty->hand_fd && res != ECORE_CALLBACK_CANCEL)
      {
-        res = _cb_fd_read(ty, ty->hand_fd);
+        res = _fd_read_do(ty, ty->hand_fd, EINA_TRUE);
      }
 
    if (ty->hand_fd) ecore_main_fd_handler_del(ty->hand_fd);

-- 


Reply via email to