aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2010-08-28 03:18:22 +0200
committerAurélien Aptel <aurelien.aptel@gmail.com>2010-08-28 03:18:22 +0200
commitcf527c22d59c57a88f721289d6d6100f50541cf2 (patch)
tree4e471277f68582713a23e5b0cd2fc57959fac89a /st.c
parentfa6a9216a1d7c6af53ed85a5ef3103b9f61bd6c3 (diff)
downloadst-cf527c22d59c57a88f721289d6d6100f50541cf2.tar.gz
st-cf527c22d59c57a88f721289d6d6100f50541cf2.tar.bz2
st now runs on Linux, OpenBSD and FreeBSD.
Diffstat (limited to 'st.c')
-rw-r--r--st.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/st.c b/st.c
index 623ca29..9ca032f 100644
--- a/st.c
+++ b/st.c
@@ -20,6 +20,14 @@
#include <X11/keysym.h>
#include <X11/Xutil.h>
+#if defined(LINUX)
+ #include <pty.h>
+#elif defined(OPENBSD)
+ #include <util.h>
+#elif defined(FREEBSD)
+ #include <libutil.h>
+#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");