summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-03-31 22:08:45 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-03-31 22:08:45 +0000
commitd13add828ad7737dea34384e7fc0bf116ffff605 (patch)
tree566c9d6e3833c847cf9fd2018cbc3b1a367a48fe
parent92594c8029db87738aa99262a8275d57ce9e520d (diff)
More AIX tweaks.
-rw-r--r--GNUmakefile4
-rw-r--r--compat/forkpty-aix.c37
-rw-r--r--tmux.h3
3 files changed, 29 insertions, 15 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 18b92976..d40aeaff 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,4 +1,4 @@
-# $Id: GNUmakefile,v 1.77 2009-03-31 21:24:33 nicm Exp $
+# $Id: GNUmakefile,v 1.78 2009-03-31 22:08:45 nicm Exp $
.PHONY: clean
@@ -76,7 +76,7 @@ SRCS+= compat/vis.c compat/strlcpy.c compat/strlcat.c compat/strtonum.c \
CFLAGS+= -DNO_TREE_H -DNO_ASPRINTF -DNO_QUEUE_H -DNO_VSYSLOG \
-DNO_PROGNAME -DNO_STRLCPY -DNO_STRLCAT -DNO_STRTONUM \
-DNO_SETPROCTITLE -DNO_QUEUE_H -DNO_TREE_H -DNO_FORKPTY -DNO_FGETLN \
- -DBROKEN_GETOPT -DBROKEN_POLL
+ -DBROKEN_GETOPT -DBROKEN_POLL -DNO_PATHS_H
LDFLAGS+= -L/usr/local/lib
endif
diff --git a/compat/forkpty-aix.c b/compat/forkpty-aix.c
index 6d4f5327..c1f59f92 100644
--- a/compat/forkpty-aix.c
+++ b/compat/forkpty-aix.c
@@ -1,4 +1,4 @@
-/* $Id: forkpty-aix.c,v 1.1 2009-03-31 21:23:18 nicm Exp $ */
+/* $Id: forkpty-aix.c,v 1.2 2009-03-31 22:08:45 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -30,18 +30,14 @@ pid_t
forkpty(int *master,
unused char *name, unused struct termios *tio, struct winsize *ws)
{
- int slave;
+ int slave, fd;
char *path;
pid_t pid;
if ((*master = open("/dev/ptc", O_RDWR|O_NOCTTY)) == -1)
return (-1);
- if (grantpt(*master) != 0)
- goto out;
- if (unlockpt(*master) != 0)
- goto out;
- if ((path = ptsname(*master)) == NULL)
+ if ((path = ttyname(*master)) == NULL)
goto out;
if ((slave = open(path, O_RDWR|O_NOCTTY)) == -1)
goto out;
@@ -52,11 +48,28 @@ forkpty(int *master,
case 0:
close(*master);
- setsid();
-#ifdef TIOCSCTTY
- if (ioctl(slave, TIOCSCTTY, NULL) == -1)
- fatal("ioctl failed");
-#endif
+ fd = open(_PATH_TTY, O_RDWR|O_NOCTTY);
+ if (fd >= 0) {
+ ioctl(fd, TIOCNOTTY, NULL);
+ close(fd);
+ }
+
+ if (setsid() < 0)
+ fatal("setsid");
+
+ fd = open(_PATH_TTY, O_RDWR|O_NOCTTY);
+ if (fd >= 0)
+ fatalx("open succeeded (failed to disconnect)");
+
+ fd = open(path, O_RDWR);
+ if (fd < 0)
+ fatal("open failed");
+ close(fd);
+
+ fd = open("/dev/tty", O_WRONLY);
+ if (fd < 0)
+ fatal("open failed");
+ close(fd);
if (ioctl(slave, TIOCSWINSZ, ws) == -1)
fatal("ioctl failed");
diff --git a/tmux.h b/tmux.h
index 94cb06cb..2a0745c1 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.292 2009-03-29 11:18:28 nicm Exp $ */
+/* $Id: tmux.h,v 1.293 2009-03-31 22:08:45 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -109,6 +109,7 @@ extern const char *__progname;
#define _PATH_BSHELL "/bin/sh"
#define _PATH_TMP "/tmp/"
#define _PATH_DEVNULL "/dev/null"
+#define _PATH_TTY "/dev/tty"
#endif
/* Default configuration file. */