summaryrefslogtreecommitdiff
path: root/st-0.8.5/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st-0.8.5/st.c')
-rw-r--r--st-0.8.5/st.c10
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