From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759263AbbA3Cy7 (ORCPT ); Thu, 29 Jan 2015 21:54:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32824 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752285AbbA3Cy6 (ORCPT ); Thu, 29 Jan 2015 21:54:58 -0500 Date: Thu, 29 Jan 2015 20:54:53 -0600 From: Josh Poimboeuf To: Steven Rostedt Cc: Satoru Takeuchi , linux-kernel@vger.kernel.org Subject: [PATCH] ktest: cleanup terminal on dodie() failure Message-ID: <20150130025453.GB20952@treble.redhat.com> References: <20150129154441.1b248e93@gandalf.local.home> <20150129213939.GA20952@treble.redhat.com> <20150129170751.0b399ecb@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150129170751.0b399ecb@gandalf.local.home> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 29, 2015 at 05:07:51PM -0500, Steven Rostedt wrote: > On Thu, 29 Jan 2015 15:39:39 -0600 > Josh Poimboeuf wrote: > > > > Can you tell if it died via dodie()? Looks like that wouldn't clean up > > the stty settings. > > > > Looks to have happen in monitor where it called: > > fail "failed - got a bug report" and return 0; > > And must have had $die_on_failure set because it did not post a KTEST > RESULT message. That means yes, it would hit dodie() called by fail(). This fixes it for me: --8<-- Subject: [PATCH] ktest: cleanup terminal on dodie() failure If dodie() is called with the console open, restore the terminal's original settings before dying. Signed-off-by: Josh Poimboeuf --- tools/testing/ktest/ktest.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index acaf05b..04e9391 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -1342,6 +1342,11 @@ sub dodie { print " See $opt{LOG_FILE} for more info.\n"; } + if ($monitor_cnt) { + # restore terminal settings + system("stty $stty_orig"); + } + die @_, "\n"; } @@ -1384,7 +1389,7 @@ sub exec_console { close($pts); exec $console or - dodie "Can't open console $console"; + die "Can't open console $console"; } sub open_console { -- 2.1.0