diff options
Diffstat (limited to 'st.c')
| -rw-r--r-- | st.c | 27 |
1 files changed, 14 insertions, 13 deletions
| @@ -20,6 +20,14 @@ | |||
| 20 | #include <X11/keysym.h> | 20 | #include <X11/keysym.h> |
| 21 | #include <X11/Xutil.h> | 21 | #include <X11/Xutil.h> |
| 22 | 22 | ||
| 23 | #if defined(LINUX) | ||
| 24 | #include <pty.h> | ||
| 25 | #elif defined(OPENBSD) | ||
| 26 | #include <util.h> | ||
| 27 | #elif defined(FREEBSD) | ||
| 28 | #include <libutil.h> | ||
| 29 | #endif | ||
| 30 | |||
| 23 | /* Arbitrary sizes */ | 31 | /* Arbitrary sizes */ |
| 24 | #define ESC_TITLE_SIZ 256 | 32 | #define ESC_TITLE_SIZ 256 |
| 25 | #define ESC_BUF_SIZ 256 | 33 | #define ESC_BUF_SIZ 256 |
| @@ -242,19 +250,12 @@ sigchld(int a) { | |||
| 242 | void | 250 | void |
| 243 | ttynew(void) { | 251 | ttynew(void) { |
| 244 | int m, s; | 252 | int m, s; |
| 245 | char *pts; | 253 | |
| 246 | 254 | /* seems to work fine on linux, openbsd and freebsd */ | |
| 247 | if((m = posix_openpt(O_RDWR | O_NOCTTY)) < 0) | 255 | struct winsize w = {term.row, term.col, 0, 0}; |
| 248 | die("openpt failed: %s\n", SERRNO); | 256 | if(openpty(&m, &s, NULL, NULL, &w) < 0) |
| 249 | if(grantpt(m) < 0) | 257 | die("openpty failed: %s\n", SERRNO); |
| 250 | die("grantpt failed: %s\n", SERRNO); | 258 | |
| 251 | if(unlockpt(m) < 0) | ||
| 252 | die("unlockpt failed: %s\n", SERRNO); | ||
| 253 | if(!(pts = ptsname(m))) | ||
| 254 | die("ptsname failed: %s\n", SERRNO); | ||
| 255 | if((s = open(pts, O_RDWR | O_NOCTTY)) < 0) | ||
| 256 | die("Couldn't open slave: %s\n", SERRNO); | ||
| 257 | fcntl(s, F_SETFL, O_NDELAY); | ||
| 258 | switch(pid = fork()) { | 259 | switch(pid = fork()) { |
| 259 | case -1: | 260 | case -1: |
| 260 | die("fork failed\n"); | 261 | die("fork failed\n"); |
