components/tmux/patches/client.c.patch
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Mon, 09 Dec 2013 23:00:29 -0800
changeset 1589 f9f1e8f54c5a
parent 1476 ab7bed457fe6
permissions -rw-r--r--
Added tag s12-37 for changeset 8117331776d5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1476
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
     1
In-House Patch. Submitted to upstream, but not accepted yet.
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
     2
Check for flock(), which is available on BSD and not on Solaris. 
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
     3
Instead use fnctl() on Solaris. Also check if cfmakeraw(), which
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
     4
is not available on Solaris, so manually change the termios 
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
     5
structure, the same way cfmakeraw does.
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
     6
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
     7
--- tmux-1.8/client.c.orig	2013-08-13 12:42:26.447337127 -0700
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
     8
+++ tmux-1.8/client.c	2013-08-13 12:44:09.044164126 -0700
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
     9
@@ -74,16 +74,30 @@
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    10
 client_get_lock(char *lockfile)
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    11
 {
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    12
 	int lockfd;
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    13
+#ifdef F_SETLK
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    14
+        struct flock lock;
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    15
+#endif
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    16
 
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    17
 	if ((lockfd = open(lockfile, O_WRONLY|O_CREAT, 0600)) == -1)
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    18
 		fatal("open failed");
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    19
 
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    20
+#ifdef F_SETLK
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    21
+        if (fcntl(lockfd, F_SETLK, &lock) == -1 && errno == EAGAIN) {
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    22
+		while (fcntl(lockfd, F_SETLKW, &lock) == -1 && errno == EINTR)
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    23
+			/* nothing */;
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    24
+		close(lockfd);
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    25
+		return(-1);
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    26
+	}
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    27
+#elif LOCK_EX
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    28
 	if (flock(lockfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK) {
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    29
 		while (flock(lockfd, LOCK_EX) == -1 && errno == EINTR)
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    30
 			/* nothing */;
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    31
 		close(lockfd);
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    32
 		return (-1);
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    33
 	}
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    34
+#else
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    35
+#error  "You need locking support."
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    36
+#endif
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    37
 
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    38
 	return (lockfd);
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    39
 }
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    40
@@ -244,7 +258,15 @@
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    41
 			    strerror(errno));
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    42
 			return (1);
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    43
 		}
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    44
-		cfmakeraw(&tio);
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    45
+#ifdef HAVE_CFMAKERAW
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    46
+                cfmakeraw(&tio);
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    47
+#else
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    48
+		tio.c_iflag &= ~(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    49
+		tio.c_oflag &= ~OPOST;
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    50
+		tio.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    51
+		tio.c_cflag &= ~(CSIZE|PARENB);
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    52
+	     	tio.c_cflag |= CS8;
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    53
+#endif
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    54
 		tio.c_iflag = ICRNL|IXANY;
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    55
 		tio.c_oflag = OPOST|ONLCR;
ab7bed457fe6 PSARC 2013/270 tmux version 1.8
mahmood.ali@oracle.com <mahmood.ali@oracle.com>
parents:
diff changeset
    56
 #ifdef NOKERNINFO