billiob pushed a commit to branch master.

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

commit d5d96cb655d2b10ff187a00f7853045ba3198c5c
Author: Boris Faure <[email protected]>
Date:   Thu Apr 2 22:56:26 2020 +0200

    termpty: only call ecore_main_fd_handler_active_set() on valid fd
    
    + reformat
---
 src/bin/termpty.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 8349097..fa402de 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -361,7 +361,7 @@ _handle_write(Termpty *ty)
      }
    ty_sb_lskip(sb, len);
 
-   if (!sb->len)
+   if (!sb->len && ty->hand_fd)
      ecore_main_fd_handler_active_set(ty->hand_fd,
                                       ECORE_FD_ERROR |
                                       ECORE_FD_READ);
@@ -437,14 +437,18 @@ _cb_exe_exit(void *data,
         res = _fd_do(ty, ty->hand_fd, EINA_TRUE);
      }
 
-   if (ty->hand_fd) ecore_main_fd_handler_del(ty->hand_fd);
+   if (ty->hand_fd)
+     ecore_main_fd_handler_del(ty->hand_fd);
    ty->hand_fd = NULL;
-   if (ty->fd >= 0) close(ty->fd);
+   if (ty->fd >= 0)
+     close(ty->fd);
    ty->fd = -1;
-   if (ty->slavefd >= 0) close(ty->slavefd);
+   if (ty->slavefd >= 0)
+     close(ty->slavefd);
    ty->slavefd = -1;
 
-   if (ty->cb.exited.func) ty->cb.exited.func(ty->cb.exited.data);
+   if (ty->cb.exited.func)
+     ty->cb.exited.func(ty->cb.exited.data);
 
    return ECORE_CALLBACK_PASS_ON;
 }
@@ -784,7 +788,7 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const 
char *cd,
         else
           {
              char *cmdfile, *cmd0;
-             
+
              cmdfile = (char *)args[0];
              cmd0 = alloca(strlen(cmdfile) + 2);
              cmd0[0] = '-';
@@ -867,8 +871,10 @@ termpty_free(Termpty *ty)
              ty->pid = -1;
           }
      }
-   if (ty->hand_exe_exit) ecore_event_handler_del(ty->hand_exe_exit);
-   if (ty->hand_fd) ecore_main_fd_handler_del(ty->hand_fd);
+   if (ty->hand_exe_exit)
+     ecore_event_handler_del(ty->hand_exe_exit);
+   if (ty->hand_fd)
+     ecore_main_fd_handler_del(ty->hand_fd);
    eina_stringshare_del(ty->prop.title);
    eina_stringshare_del(ty->prop.user_title);
    eina_stringshare_del(ty->prop.icon);
@@ -1188,7 +1194,7 @@ termpty_write(Termpty *ty, const char *input, int len)
      {
         ERR("failure to add %d characters to write buffer", len);
      }
-   else
+   else if (ty->hand_fd)
      {
         ecore_main_fd_handler_active_set(ty->hand_fd,
                                          ECORE_FD_ERROR |

-- 


Reply via email to