components/tmux/patches/client.c.patch
author Petr Sumbera <petr.sumbera@oracle.com>
Thu, 05 Jun 2014 14:04:04 -0700
changeset 1936 185320167a36
parent 1476 ab7bed457fe6
permissions -rw-r--r--
18908082 some apache2 modules don't build on 49

In-House Patch. Submitted to upstream, but not accepted yet.
Check for flock(), which is available on BSD and not on Solaris. 
Instead use fnctl() on Solaris. Also check if cfmakeraw(), which
is not available on Solaris, so manually change the termios 
structure, the same way cfmakeraw does.

--- tmux-1.8/client.c.orig	2013-08-13 12:42:26.447337127 -0700
+++ tmux-1.8/client.c	2013-08-13 12:44:09.044164126 -0700
@@ -74,16 +74,30 @@
 client_get_lock(char *lockfile)
 {
 	int lockfd;
+#ifdef F_SETLK
+        struct flock lock;
+#endif
 
 	if ((lockfd = open(lockfile, O_WRONLY|O_CREAT, 0600)) == -1)
 		fatal("open failed");
 
+#ifdef F_SETLK
+        if (fcntl(lockfd, F_SETLK, &lock) == -1 && errno == EAGAIN) {
+		while (fcntl(lockfd, F_SETLKW, &lock) == -1 && errno == EINTR)
+			/* nothing */;
+		close(lockfd);
+		return(-1);
+	}
+#elif LOCK_EX
 	if (flock(lockfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK) {
 		while (flock(lockfd, LOCK_EX) == -1 && errno == EINTR)
 			/* nothing */;
 		close(lockfd);
 		return (-1);
 	}
+#else
+#error  "You need locking support."
+#endif
 
 	return (lockfd);
 }
@@ -244,7 +258,15 @@
 			    strerror(errno));
 			return (1);
 		}
-		cfmakeraw(&tio);
+#ifdef HAVE_CFMAKERAW
+                cfmakeraw(&tio);
+#else
+		tio.c_iflag &= ~(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
+		tio.c_oflag &= ~OPOST;
+		tio.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+		tio.c_cflag &= ~(CSIZE|PARENB);
+	     	tio.c_cflag |= CS8;
+#endif
 		tio.c_iflag = ICRNL|IXANY;
 		tio.c_oflag = OPOST|ONLCR;
 #ifdef NOKERNINFO