X-Git-Url: https://jasonwoof.com/gitweb/?p=st.git;a=blobdiff_plain;f=st.c;h=9ca032f5a34a221787ca53235fc5021e9ffd2cb0;hp=623ca29cd71e56936bfc2c6f48fb769564dab178;hb=6db6980e27bdde6f2d444dd3cdd7a46985fa84fc;hpb=c56332857145d1c6741d4f6c1bbc87dcc6c6ab97 diff --git a/st.c b/st.c index 623ca29..9ca032f 100644 --- a/st.c +++ b/st.c @@ -20,6 +20,14 @@ #include #include +#if defined(LINUX) + #include +#elif defined(OPENBSD) + #include +#elif defined(FREEBSD) + #include +#endif + /* Arbitrary sizes */ #define ESC_TITLE_SIZ 256 #define ESC_BUF_SIZ 256 @@ -242,19 +250,12 @@ sigchld(int a) { void ttynew(void) { int m, s; - char *pts; - - if((m = posix_openpt(O_RDWR | O_NOCTTY)) < 0) - die("openpt failed: %s\n", SERRNO); - if(grantpt(m) < 0) - die("grantpt failed: %s\n", SERRNO); - if(unlockpt(m) < 0) - die("unlockpt failed: %s\n", SERRNO); - if(!(pts = ptsname(m))) - die("ptsname failed: %s\n", SERRNO); - if((s = open(pts, O_RDWR | O_NOCTTY)) < 0) - die("Couldn't open slave: %s\n", SERRNO); - fcntl(s, F_SETFL, O_NDELAY); + + /* seems to work fine on linux, openbsd and freebsd */ + struct winsize w = {term.row, term.col, 0, 0}; + if(openpty(&m, &s, NULL, NULL, &w) < 0) + die("openpty failed: %s\n", SERRNO); + switch(pid = fork()) { case -1: die("fork failed\n");