tcmd: fix cmd_pipe() on OpenBSD - neatvi - [fork] simple vi-type editor with UTF-8 support
 (HTM) git clone git://src.adamsgaard.dk/neatvi
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) commit 62df24f12c33e086991d6bee683289848f98daa7
 (DIR) parent aae3a82a9f44f2b7fe2b6babb9390ad23517172a
 (HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
       Date:   Tue, 28 Jul 2020 00:11:36 +0430
       
       cmd: fix cmd_pipe() on OpenBSD
       
       Reported and tested by Dirk-Wilhelm Peters <peters@schwertfisch.de>.
       
       Diffstat:
         M cmd.c                               |      12 ++++++------
       
       1 file changed, 6 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/cmd.c b/cmd.c
       t@@ -84,8 +84,6 @@ char *cmd_pipe(char *cmd, char *ibuf, int iproc, int oproc)
                                        sbuf_mem(sb, buf, ret);
                                if (ret < 0)
                                        close(fds[0].fd);
       -                } else if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) {
       -                        fds[0].fd = -1;
                        }
                        if (fds[1].revents & POLLOUT) {
                                int ret = write(fds[1].fd, ibuf + nw, slen - nw);
       t@@ -93,8 +91,6 @@ char *cmd_pipe(char *cmd, char *ibuf, int iproc, int oproc)
                                        nw += ret;
                                if (ret <= 0 || nw == slen)
                                        close(fds[1].fd);
       -                } else if (fds[1].revents & (POLLERR | POLLHUP | POLLNVAL)) {
       -                        fds[1].fd = -1;
                        }
                        if (fds[2].revents & POLLIN) {
                                int ret = read(fds[2].fd, buf, sizeof(buf));
       t@@ -102,9 +98,13 @@ char *cmd_pipe(char *cmd, char *ibuf, int iproc, int oproc)
                                for (i = 0; i < ret; i++)
                                        if ((unsigned char) buf[i] == TK_CTL('c'))
                                                kill(pid, SIGINT);
       -                } else if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) {
       -                        fds[2].fd = -1;
                        }
       +                if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL))
       +                        fds[0].fd = -1;
       +                if (fds[1].revents & (POLLERR | POLLHUP | POLLNVAL))
       +                        fds[1].fd = -1;
       +                if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL))
       +                        fds[2].fd = -1;
                }
                close(ifd);
                close(ofd);