aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-12-13 11:53:50 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-12-13 11:53:50 +0900
commit60d1c6d05c85d6af9448e0110218bb5a7e550b4b (patch)
tree4b73e09eee78140bc140b38c5902a5d7bd3d3a41
parenttermio: small cleanup (diff)
downloadterminology-60d1c6d05c85d6af9448e0110218bb5a7e550b4b.tar.gz
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
-rw-r--r--src/bin/termpty.c13
1 files 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);