From: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>

Make generic_console_write() catch the EINTR error code and retry doing the
calls accordingly.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/um/drivers/chan_user.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff -puN arch/um/drivers/chan_user.c~uml-catch-eintr-in-generic_console_write arch/um/drivers/chan_user.c
--- 25/arch/um/drivers/chan_user.c~uml-catch-eintr-in-generic_console_write	2004-11-03 19:27:55.110412440 -0800
+++ 25-akpm/arch/um/drivers/chan_user.c	2004-11-03 19:27:55.115411680 -0800
@@ -27,14 +27,26 @@ int generic_console_write(int fd, const 
 	int err;
 
 	if(isatty(fd)){
-		tcgetattr(fd, &save);
+		CATCH_EINTR(err = tcgetattr(fd, &save));
+		if (err)
+			goto error;
 		new = save;
+		/* The terminal becomes a bit less raw, to handle \n also as
+		 * "Carriage Return", not only as "New Line". Otherwise, the new
+		 * line won't start at the first column.*/
 		new.c_oflag |= OPOST;
-		tcsetattr(fd, TCSAFLUSH, &new);
+		CATCH_EINTR(err = tcsetattr(fd, TCSAFLUSH, &new));
+		if (err)
+			goto error;
 	}
 	err = generic_write(fd, buf, n, NULL);
-	if(isatty(fd)) tcsetattr(fd, TCSAFLUSH, &save);
+	/* Restore raw mode, in any case; we *must* ignore any error apart
+	 * EINTR, except for debug.*/
+	if(isatty(fd))
+		CATCH_EINTR(tcsetattr(fd, TCSAFLUSH, &save));
 	return(err);
+error:
+	return(-errno);
 }
 
 static void winch_handler(int sig)
_