components/tmux/patches/client.c.patch
author Misaki Miyashita <Misaki.Miyashita@Oracle.COM>
Fri, 14 Nov 2014 07:56:14 -0800
changeset 2207 64e8c961a4a2
parent 1476 ab7bed457fe6
permissions -rw-r--r--
20018650 openssl-1.0.1-fips-140 x86 build tries to apply sparc patch to x86 file 19230646 "openssl speed -multi" fails with pkcs11 engine

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