[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] tools/console: reset tty when xenconsole fails



commit 111931f36885874103d65685ab15ea3d25d93da7
Author:     Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
AuthorDate: Mon Feb 24 15:16:19 2014 +0000
Commit:     Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CommitDate: Wed Mar 19 13:37:19 2014 +0000

    tools/console: reset tty when xenconsole fails
    
    If xenconsole (the client program) fails, it calls err.  This would
    previously neglect to reset the user's terminal to sanity.  Use atexit
    to do so.
    
    This routinely happens in Xen 4.4 RC5 with pygrub because libxl
    writes the value "" to the tty xenstore key when using xenconsole.
    After this patch this just results in a harmless error message.
    
    Reported-by: M A Young <m.a.young@xxxxxxxxxxxx>
    Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
    CC: M A Young <m.a.young@xxxxxxxxxxxx>
    CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
    Acked-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
    
    ---
    v2: Fix whitespace error (reintroduce hard tab)
        Fix commit message not to claim ignorance about root cause
---
 tools/console/client/main.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/console/client/main.c b/tools/console/client/main.c
index eb6a1a9..7ce4f24 100644
--- a/tools/console/client/main.c
+++ b/tools/console/client/main.c
@@ -257,6 +257,13 @@ typedef enum {
        CONSOLE_SERIAL,
 } console_type;
 
+static struct termios stdin_old_attr;
+
+static void restore_term_stdin(void)
+{
+       restore_term(STDIN_FILENO, &stdin_old_attr);
+}
+
 int main(int argc, char **argv)
 {
        struct termios attr;
@@ -383,9 +390,9 @@ int main(int argc, char **argv)
        }
 
        init_term(spty, &attr);
-       init_term(STDIN_FILENO, &attr);
+       init_term(STDIN_FILENO, &stdin_old_attr);
+       atexit(restore_term_stdin); /* if this fails, oh dear */
        console_loop(spty, xs, path);
-       restore_term(STDIN_FILENO, &attr);
 
        free(path);
        free(dom_path);
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.