File ksh93-builtin.dif of Package ksh

--- src/cmd/builtin/pty.c
+++ src/cmd/builtin/pty.c	2013-02-01 15:59:52.697952156 +0000
@@ -216,13 +216,19 @@ 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(STDERR_FILENO, &tty) >= 0)
+	alarm(6);
+	if (tcgetattr(sffileno(sfstderr), &tty) >= 0)
 		ttyp = &tty;
 	else
 	{
@@ -230,7 +236,7 @@ mkpty(int* master, int* slave)
 		error(-1, "unable to get standard error terminal attributes");
 	}
 #ifdef TIOCGWINSZ
-	if (ioctl(STDERR_FILENO, TIOCGWINSZ, &win) >= 0)
+	if (ioctl(sffileno(sfstderr), TIOCGWINSZ, &win) >= 0)
 		winp = &win;
 	else
 	{
@@ -238,6 +244,12 @@ mkpty(int* master, int* slave)
 		error(-1, "unable to get standard error window size");
 	}
 #endif
+#ifdef __linux__
+# if !_lib_openpty
+#  undef  _lib_openpty
+#  define _lib_openpty 1
+# endif
+#endif
 #if _lib_openpty
 	if (openpty(master, slave, NULL, ttyp, winp) < 0)
 		return -1;
@@ -279,6 +291,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;
 }
@@ -317,9 +332,13 @@ process(Sfio_t* mp, Sfio_t* lp, int dela
 	char*		s;
 	Sfio_t*		ip;
 	Sfio_t*		sps[2];
+	struct stat	dst;
+	struct stat	fst;
 
 	ip = sfstdin;
-	for (;;)
+	if (!fstat(sffileno(ip), &dst) && !stat("/dev/null", &fst) && dst.st_dev == fst.st_dev && dst.st_ino == fst.st_ino)
+		ip = 0;
+	do
 	{
 		i = 0;
 		t = timeout;
@@ -336,39 +355,39 @@ process(Sfio_t* mp, Sfio_t* lp, int dela
 		{
 			if (n < 0)
 				error(ERROR_SYSTEM|2, "poll failed");
-			if (t < 0)
-				break;
+			break;
 		}
-		else
-			for (i = 0; i < n; i++)
+		for (i = t = 0; i < n; i++)
+		{
+			if (!(sfvalue(sps[i]) & SF_READ))
+				/*skip*/;
+			else if (sps[i] == mp)
 			{
-				if (!(sfvalue(sps[i]) & SF_READ))
-					/*skip*/;
-				else if (sps[i] == mp)
+				t++;
+				if (!(s = (char*)sfreserve(mp, SF_UNBOUND, -1)))
 				{
-					if (!(s = (char*)sfreserve(mp, SF_UNBOUND, -1)))
-					{
-						sfclose(mp);
-						mp = 0;
-					}
-					else if ((r = sfvalue(mp)) > 0 && (sfwrite(sfstdout, s, r) != r || sfsync(sfstdout)))
-					{
-						error(ERROR_SYSTEM|2, "output write failed");
-						goto done;
-					}
+					sfclose(mp);
+					mp = 0;
 				}
-				else
+				else if ((r = sfvalue(mp)) > 0 && (sfwrite(sfstdout, s, r) != r || sfsync(sfstdout)))
 				{
-					if (!(s = sfgetr(ip, '\n', 1)))
-						ip = 0;
-					else if (sfputr(mp, s, '\r') < 0 || sfsync(mp))
-					{
-						error(ERROR_SYSTEM|2, "write failed");
-						goto done;
-					}
+					error(ERROR_SYSTEM|2, "output write failed");
+					goto done;
 				}
 			}
-	}
+			else
+			{
+				t++;
+				if (!(s = sfgetr(ip, '\n', 1)))
+					ip = 0;
+				else if (sfputr(mp, s, '\r') < 0 || sfsync(mp))
+				{
+					error(ERROR_SYSTEM|2, "write failed");
+					goto done;
+				}
+			}
+		}
+	} while (t);
  done:
 	if (mp)
 		sfclose(mp);
--- src/cmd/builtin/what.c
+++ src/cmd/builtin/what.c	2012-02-13 11:02:18.645933606 +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