2004-11-04 02:06:57

by Blaisorblade

[permalink] [raw]
Subject: [patch 10/20] uml: catch EINTR in generic_console_write


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

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[email protected]>
---

vanilla-linux-2.6.9-paolo/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_generic_console_write arch/um/drivers/chan_user.c
--- vanilla-linux-2.6.9/arch/um/drivers/chan_user.c~uml-catch_eintr_generic_console_write 2004-11-03 23:44:59.720481224 +0100
+++ vanilla-linux-2.6.9-paolo/arch/um/drivers/chan_user.c 2004-11-03 23:44:59.722480920 +0100
@@ -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);
}

struct winch_data {
_