diff options
| author | stkhan <personal@slickd.xyz> | 2022-05-26 20:55:41 +0000 |
|---|---|---|
| committer | stkhan <personal@slickd.xyz> | 2022-05-26 20:55:41 +0000 |
| commit | c9a6277b4c5a08d587396c7bf597286d7b6efdaa (patch) | |
| tree | f1f5fdfd9656f8f5e93bd7715e73fe51e0a05d93 /st-0.8.5/st.c | |
| parent | 2016aeaa085bc37b4c5d01d6bcf12cdfd2235ca1 (diff) | |
Added graphics patch
Diffstat (limited to 'st-0.8.5/st.c')
| -rw-r--r-- | st-0.8.5/st.c | 10 |
1 files changed, 7 insertions, 3 deletions
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 |