From: Ian Campbell Subject: Re: [PATCH] tools/console: reset tty when xenconsole fails Date: Mon, 24 Feb 2014 15:42:43 +0000 Message-ID: <1393256563.16570.88.camel@kazak.uk.xensource.com> References: <1393255564-3474-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1393255564-3474-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: George Dunlap , xen-devel@lists.xensource.com, M A Young List-Id: xen-devel@lists.xenproject.org On Mon, 2014-02-24 at 15:26 +0000, Ian Jackson wrote: > 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 something > writes the value "" to the tty xenstore key when using xenconsole. > The cause of this is not yet known, but after this patch it just > results in a harmless error message. > > Reported-by: M A Young > Signed-off-by: Ian Jackson > CC: Ian Campbell > CC: George Dunlap > --- > tools/console/client/main.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/tools/console/client/main.c b/tools/console/client/main.c > index 3242008..add3313 100644 > --- a/tools/console/client/main.c > +++ b/tools/console/client/main.c > @@ -258,6 +258,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; > @@ -384,9 +391,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 */ Looks like some sort of tab/space damage, but otherwise: Acked-by: Ian Campbell > console_loop(spty, xs, path); > - restore_term(STDIN_FILENO, &attr); > > free(path); > free(dom_path);