linux-um archives
 help / color / mirror / Atom feed
From: BlaisorBlade <blaisorblade_spam@yahoo.it>
To: user-mode-linux-devel@lists.sourceforge.net
Cc: Matt Clay <mattclay@hevanet.com>
Subject: Re: [uml-devel] tcsetattr returning -1, errno = EINTR
Date: Tue, 24 Aug 2004 17:35:24 +0200	[thread overview]
Message-ID: <200408241735.25186.blaisorblade_spam@yahoo.it> (raw)
In-Reply-To: <41109B81.3030202@hevanet.com>

[-- Attachment #1: Type: text/plain, Size: 1224 bytes --]

Alle 10:17, mercoledì 4 agosto 2004, Matt Clay ha scritto:
> While booting UML in skas mode, I've noticed occasional glitches in the
> console output during the boot process.  At first I thought this was
> related to bug #260111, but now that Allen Chan has found the cause, I'm
> still having this problem after using the move_console_write patch.
>
> Sometimes the console output shows up like this:
>
> <snip>
> NET4: Linux TCP/IP 1.0 for NET4.0
>                                   IP Protocols: ICMP, UDP, TCP
> IP: routing cache hash table of 512 buckets, 4Kbytes
> <snip>
>
> I've tracked this back to calls to tcsetattr failing in
> generic_console_write.  It returns -1, and sets errno to 4 (EINTR).  I
> don't know if failed calls should be restarted or not, but I'm pretty sure
> ignoring the errors isn't a good idea.
Yes, it should be restarted.

For avoiding too much boilerplate in such cases, see the CATCH_EINTR macro 
added in the catch-eintr patch (included in the late 2.4 and 2.6 -um trees, 
see the changelogs for the links). See the attached code, and give an opinion 
- I'm not sure it is the exact one.
-- 
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729

[-- Attachment #2: uml-catch_eintr_generic_console_write.patch --]
[-- Type: text/x-diff, Size: 1542 bytes --]



Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
---

 uml-linux-2.6.7-paolo/arch/um/drivers/chan_user.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff -puN arch/um/drivers/chan_user.c~catch_eintr_generic_console_write arch/um/drivers/chan_user.c
--- uml-linux-2.6.7/arch/um/drivers/chan_user.c~catch_eintr_generic_console_write	2004-08-24 17:13:31.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/drivers/chan_user.c	2004-08-24 17:30:22.000000000 +0200
@@ -31,23 +31,32 @@ struct winch_data {
 	int close_me;
 };
 
-/* XXX This breaks horribly (by hanging UML) when moved to chan_kern.c - 
- * needs investigation
- */
 int generic_console_write(int fd, const char *buf, int n, void *unused)
 {
 	struct termios save, new;
 	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".*/
 		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));
+out:
 	return(err);
+error:
+	return(-errno);
 }
 
 static int winch_thread(void *arg)
_

      reply	other threads:[~2004-08-29 21:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-04  8:17 [uml-devel] tcsetattr returning -1, errno = EINTR Matt Clay
2004-08-24 15:35 ` BlaisorBlade [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200408241735.25186.blaisorblade_spam@yahoo.it \
    --to=blaisorblade_spam@yahoo.it \
    --cc=mattclay@hevanet.com \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox