diff options
author | rsc <devnull@localhost> | 2004-03-25 23:03:57 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2004-03-25 23:03:57 +0000 |
commit | 8ad517944e46710ab832350c0dc3fc4e9239f7e2 (patch) | |
tree | 7b99a1833e1b303719c2aac75e3f7e82482b42ab /src/cmd/9term/Linux.c | |
parent | cb27443abf3d6af6ab52377c71c843e619928433 (diff) | |
download | plan9port-8ad517944e46710ab832350c0dc3fc4e9239f7e2.tar.gz plan9port-8ad517944e46710ab832350c0dc3fc4e9239f7e2.tar.bz2 plan9port-8ad517944e46710ab832350c0dc3fc4e9239f7e2.zip |
Today's changes.
More changes.
Diffstat (limited to 'src/cmd/9term/Linux.c')
-rw-r--r-- | src/cmd/9term/Linux.c | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/src/cmd/9term/Linux.c b/src/cmd/9term/Linux.c index 7dd22371..872417e6 100644 --- a/src/cmd/9term/Linux.c +++ b/src/cmd/9term/Linux.c @@ -1,22 +1,46 @@ +#include <u.h> +#include <termios.h> +#include <sys/termios.h> +#include <pty.h> +#include <libc.h> #include "9term.h" int -getchildwd(int pid, char *wdir, int bufn) +getpts(int fd[], char *slave) { - char path[256]; - int n; - - snprint(path, sizeof path, "/proc/%d/cwd", pid); - n = readlink(path, wdir, bufn); - if(n < 0) - return -1; - wdir[n] = '\0'; + openpty(&fd[1], &fd[0], slave, 0, 0); return 0; } int -getpts(int fd[], char *slave) +childpty(int fd[], char *slave) { - openpty(&fd[1], &fd[0], slave, 0, 0); - return 0; + int sfd; + + close(fd[1]); + setsid(); + sfd = open(slave, ORDWR); + if(sfd < 0) + sysfatal("open %s: %r\n", slave); + if(ioctl(sfd, TIOCSCTTY, 0) < 0) + fprint(2, "ioctl TIOCSCTTY: %r\n"); + return sfd; } + +struct winsize ows; + +void +updatewinsize(int row, int col, int dx, int dy) +{ + struct winsize ws; + + ws.ws_row = row; + ws.ws_col = col; + ws.ws_xpixel = dx; + ws.ws_ypixel = dy; + if(ws.ws_row != ows.ws_row || ws.ws_col != ows.ws_col) + if(ioctl(rcfd[0], TIOCSWINSZ, &ws) < 0) + fprint(2, "ioctl: %r\n"); + ows = ws; +} + |