From: Ian Jackson Subject: Re: [PATCH v2 1/2] tools/console: reset tty when xenconsole fails Date: Thu, 20 Mar 2014 11:37:34 +0000 Message-ID: <21290.54014.688733.944917@mariner.uk.xensource.com> References: <21288.35166.479652.469692@mariner.uk.xensource.com> <1395165628-1838-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: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Anthony Liguori Cc: George Dunlap , xen-devel@lists.xensource.com, Ian Campbell , M A Young List-Id: xen-devel@lists.xenproject.org Anthony Liguori writes ("Re: [Xen-devel] [PATCH v2 1/2] tools/console: reset tty when xenconsole fails"): > On Tue, Mar 18, 2014 at 11:00 AM, Ian Jackson wrote: ... > > 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 */ > > You may want to consider using a signal handler too. atexit() isn't > called when exiting due to SIGTERM or SIGSEGV. That's would be quite exciting. I doubt tcsetattr is async-signal safe. We could prat about with sigprocmask and pselect perhaps, but that's more than I want to do right now (or, indeed, soon). In practice, the shell will normally restore the terminal in this situation. Ian.