Created
February 24, 2013 11:11
-
-
Save ichizok/5023437 to your computer and use it in GitHub Desktop.
TMUX patch for Solaris
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Makefile.am b/Makefile.am | |
index 726582a..30b8ca5 100644 | |
--- a/Makefile.am | |
+++ b/Makefile.am | |
@@ -50,11 +50,12 @@ endif | |
# Set flags for Solaris. | |
if IS_SUNOS | |
-CPPFLAGS += -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS | |
+CPPFLAGS += -D_XPG6 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS | |
endif | |
# Set flags for Sun CC. | |
if IS_SUNCC | |
+CFLAGS += -xc99 -xO3 -native | |
CFLAGS += -erroff=E_EMPTY_DECLARATION | |
endif | |
diff --git a/compat/forkpty-sunos.c b/compat/forkpty-sunos.c | |
index 90452f8..878c200 100644 | |
--- a/compat/forkpty-sunos.c | |
+++ b/compat/forkpty-sunos.c | |
@@ -21,54 +21,81 @@ | |
#include <fcntl.h> | |
#include <stdlib.h> | |
+#include <string.h> | |
#include <stropts.h> | |
#include <unistd.h> | |
+#include <poll.h> | |
#include "tmux.h" | |
+static void | |
+process_synchronize(int fd, int cue) | |
+{ | |
+ char b = 0x20; | |
+ | |
+ if (cue) { | |
+ (void)write(fd, &b, 1); | |
+ } else { | |
+ struct pollfd p; | |
+ int timeout = 3000; | |
+ | |
+ p.fd = fd; | |
+ p.events = POLLIN; | |
+ | |
+ if (poll(&p, 1, timeout) > 0) | |
+ (void)read(fd, &b, 1); | |
+ } | |
+} | |
+ | |
pid_t | |
-forkpty(int *master, char *name, struct termios *tio, struct winsize *ws) | |
+forkpty(int *amaster, char *name, struct termios *tio, struct winsize *ws) | |
{ | |
- int slave; | |
+ int master = -1; | |
+ int slave = -1; | |
char *path; | |
pid_t pid; | |
- if ((*master = open("/dev/ptmx", O_RDWR|O_NOCTTY)) == -1) | |
+ if ((master = open("/dev/ptmx", O_RDWR|O_NOCTTY)) == -1) | |
return (-1); | |
- if (grantpt(*master) != 0) | |
+ if (grantpt(master) != 0) | |
goto out; | |
- if (unlockpt(*master) != 0) | |
+ if (unlockpt(master) != 0) | |
goto out; | |
- if ((path = ptsname(*master)) == NULL) | |
+ if ((path = ptsname(master)) == NULL) | |
goto out; | |
- if (name != NULL) | |
- strlcpy(name, path, TTY_NAME_MAX); | |
if ((slave = open(path, O_RDWR|O_NOCTTY)) == -1) | |
goto out; | |
+ if (name != NULL) | |
+ strlcpy(name, path, TTY_NAME_MAX); | |
switch (pid = fork()) { | |
case -1: | |
goto out; | |
case 0: | |
- close(*master); | |
+ close(master); | |
setsid(); | |
+ | |
#ifdef TIOCSCTTY | |
if (ioctl(slave, TIOCSCTTY, NULL) == -1) | |
fatal("ioctl failed"); | |
#endif | |
- | |
if (ioctl(slave, I_PUSH, "ptem") == -1) | |
fatal("ioctl failed"); | |
if (ioctl(slave, I_PUSH, "ldterm") == -1) | |
fatal("ioctl failed"); | |
+ if (ioctl(slave, I_PUSH, "ttcompat") == -1) | |
+ fatal("ioctl failed"); | |
if (tio != NULL && tcsetattr(slave, TCSAFLUSH, tio) == -1) | |
fatal("tcsetattr failed"); | |
- if (ioctl(slave, TIOCSWINSZ, ws) == -1) | |
+ | |
+ if (ws != NULL && ioctl(slave, TIOCSWINSZ, ws) == -1) | |
fatal("ioctl failed"); | |
+ process_synchronize(slave, 1); | |
+ | |
dup2(slave, 0); | |
dup2(slave, 1); | |
dup2(slave, 2); | |
@@ -77,12 +104,15 @@ forkpty(int *master, char *name, struct termios *tio, struct winsize *ws) | |
return (0); | |
} | |
+ process_synchronize(master, 0); | |
+ | |
+ *amaster = master; | |
close(slave); | |
return (pid); | |
out: | |
- if (*master != -1) | |
- close(*master); | |
+ if (master != -1) | |
+ close(master); | |
if (slave != -1) | |
close(slave); | |
return (-1); | |
diff --git a/configure.ac b/configure.ac | |
index 590b9db..4519efc 100644 | |
--- a/configure.ac | |
+++ b/configure.ac | |
@@ -135,7 +135,7 @@ fi | |
# Look for curses. | |
AC_SEARCH_LIBS( | |
setupterm, | |
- [terminfo curses ncurses], | |
+ [terminfo ncurses curses], | |
found_curses=yes, | |
found_curses=no | |
) | |
diff --git a/server-client.c b/server-client.c | |
index 1c15a55..1363b6a 100644 | |
--- a/server-client.c | |
+++ b/server-client.c | |
@@ -19,7 +19,6 @@ | |
#include <sys/types.h> | |
#include <sys/ioctl.h> | |
-#include <errno.h> | |
#include <event.h> | |
#include <fcntl.h> | |
#include <stdlib.h> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment