From c9a6277b4c5a08d587396c7bf597286d7b6efdaa Mon Sep 17 00:00:00 2001 From: stkhan Date: Thu, 26 May 2022 20:55:41 +0000 Subject: Added graphics patch --- st-0.8.5/st.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'st-0.8.5/st.c') diff --git a/st-0.8.5/st.c b/st-0.8.5/st.c index f9e24ba..3c2646a 100644 --- a/st-0.8.5/st.c +++ b/st-0.8.5/st.c @@ -775,10 +775,11 @@ stty(char **args) perror("Couldn't call stty"); } -int +TTYConn ttynew(const char *line, char *cmd, const char *out, char **args) { int m, s; + int mypipe[2]; if (out) { term.mode |= MODE_PRINT; @@ -789,6 +790,7 @@ ttynew(const char *line, char *cmd, const char *out, char **args) out, strerror(errno)); } } + pipe(mypipe); if (line) { if ((cmdfd = open(line, O_RDWR)) < 0) @@ -796,7 +798,7 @@ ttynew(const char *line, char *cmd, const char *out, char **args) line, strerror(errno)); dup2(cmdfd, 0); stty(args); - return cmdfd; + return (TTYConn){ cmdfd, cmdfd }; } /* seems to work fine on linux, openbsd and freebsd */ @@ -814,6 +816,7 @@ ttynew(const char *line, char *cmd, const char *out, char **args) dup2(s, 0); dup2(s, 1); dup2(s, 2); + dup2(mypipe[1], 3); if (ioctl(s, TIOCSCTTY, NULL) < 0) die("ioctl TIOCSCTTY failed: %s\n", strerror(errno)); if (s > 2) @@ -830,11 +833,12 @@ ttynew(const char *line, char *cmd, const char *out, char **args) die("pledge\n"); #endif close(s); + close(mypipe[1]); cmdfd = m; signal(SIGCHLD, sigchld); break; } - return cmdfd; + return (TTYConn){ .cmdfd = cmdfd, .pipefd = mypipe[0] }; } size_t -- cgit v1.2.3