File ksh93-builtin.dif of Package ksh

--- src/cmd/builtin/pty.c
+++ src/cmd/builtin/pty.c	2014-02-18 14:37:47.047276323 +0000
@@ -113,6 +113,13 @@ USAGE_LICENSE
 #include <sys/stat.h>
 #include "FEATURE/pty"
 
+#ifdef __linux__
+# if !_lib_openpty
+#  undef  _lib_openpty
+#  define _lib_openpty 1
+# endif
+#endif
+
 #define MODE_666	(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
 #define MAXNAME		64
 
@@ -216,27 +223,59 @@ mkpty(int* master, int* slave)
 #if !_lib_openpty
 	char*		sname;
 #endif
+#ifdef __linux__
+	sigset_t blckttou, oldset;
+	(void)sigemptyset(&blckttou);
+	(void)sigaddset(&blckttou, SIGTTOU);
+	sigprocmask(SIG_BLOCK, &blckttou, &oldset);
+#endif
 	/*
 	 * some systems hang hard during the handshake
 	 * if you know why then please let us know
 	 */
 
-	alarm(4);
-	if (tcgetattr(sffileno(sfstderr), &tty) >= 0)
-		ttyp = &tty;
-	else
+	alarm(6);
+	if (tcgetattr(sffileno(sfstderr), &tty) < 0)
 	{
+		if (errno != ENOTTY)
+			error(-1, "unable to get standard error terminal attributes");
+		cfmakeraw(&tty);
 		ttyp = 0;
-		error(-1, "unable to get standard error terminal attributes");
 	}
+	tty.c_lflag |= ICANON | IEXTEN | ISIG | ECHO|ECHOE|ECHOK|ECHOKE;
+	tty.c_oflag |= (ONLCR | OPOST);
+	tty.c_oflag &= ~(OCRNL | ONLRET);
+	tty.c_iflag |= BRKINT;
+	tty.c_iflag &= ~IGNBRK;
+	tty.c_lflag |= ISIG;
+	tty.c_cc[VTIME] = 0;
+	tty.c_cc[VMIN] = CMIN;
+#ifdef B115200
+	cfsetispeed(&tty, B115200);
+	cfsetospeed(&tty, B115200);
+#elif defined(B57600)
+	cfsetispeed(&tty, B57600);
+	cfsetospeed(&tty, B57600);
+#elif defined(B38400)
+	cfsetispeed(&tty, B38400);
+	cfsetospeed(&tty, B38400);
+#endif
+        ttyp = &tty;
+
 #ifdef TIOCGWINSZ
-	if (ioctl(sffileno(sfstderr), TIOCGWINSZ, &win) >= 0)
-		winp = &win;
-	else
+	if (ioctl(sffileno(sfstderr), TIOCGWINSZ, &win) < 0)
 	{
+		if (errno != ENOTTY)
+			error(-1, "unable to get standard error window size");
+		win.ws_row = 0;
+		win.ws_col = 0;
 		winp = 0;
-		error(-1, "unable to get standard error window size");
 	}
+	if (win.ws_row < 24)
+		win.ws_row = 24;
+	if (win.ws_col < 80)
+		win.ws_col = 80;
+	winp = &win;
 #endif
 #if _lib_openpty
 	if (openpty(master, slave, NULL, ttyp, winp) < 0)
@@ -279,6 +318,9 @@ mkpty(int* master, int* slave)
 #if !O_cloexec
 	fcntl(*slave, F_SETFD, FD_CLOEXEC);
 #endif
+#ifdef __linux__
+	sigprocmask(SIG_SETMASK, &oldset, NULL);
+#endif
 	alarm(0);
 	return 0;
 }
--- src/cmd/builtin/what.c
+++ src/cmd/builtin/what.c	2014-02-18 14:29:07.979144811 +0000
@@ -68,7 +68,7 @@ static struct
 	int		match;
 	int		single;
 	size_t		skip[UCHAR_MAX+1];
-	unsigned char	prev[3];
+	unsigned char	prev[4];
 } state;
 
 static void
@@ -99,7 +99,7 @@ what(const char* file, Sfio_t* ip, Sfio_
 			{
 			next:
 				s = state.prev;
-				s[0] = s[1] = s[2] = 0;
+				s[0] = s[1] = s[2] = s[3] = 0;
 				switch (mid)
 				{
 				default:
openSUSE Build Service is sponsored by