Skip to content

Commit

Permalink
ktest: Restore tty settings after closing console
Browse files Browse the repository at this point in the history
When ktest runs the console program as a child process, the parent and
child share the same tty for stdin and stderr.  This is problematic when
using a libvirt target.  The "virsh console" program makes a lot of
changes to the tty settings, making ktest's output hard to read
(carriage returns don't work).  After ktest exits, the terminal is
unusable (CRs broken, stdin isn't echoed).

I think the best way to fix this issue would be to create a
pseudoterminal (pty pair) so the child process would have a dedicated
tty, and then use pipes to connect the two ttys.  I'm not sure if that's
overkill, but it's far beyond my current Perl abilities.

This patch is a much easier way to (partially) fix this issue.  It saves
the tty settings before opening the console and restores them after
closing it.  There are still a few places where ktest prints mangled
output while the console is open, but the output is much more legible
overall, and the terminal works just fine after ktest exits.

Link: http://lkml.kernel.org/r/1bb89abc0025cf1d6da657c7ba58bbeb4381a515.1422382008.git.jpoimboe@redhat.com

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Josh Poimboeuf authored and Steven Rostedt committed Jan 27, 2015
1 parent b53486e commit 9884278
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/testing/ktest/ktest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
my $localversion;
my $iteration = 0;
my $successes = 0;
my $stty;

my $bisect_good;
my $bisect_bad;
Expand Down Expand Up @@ -1349,6 +1350,9 @@ sub open_console {

my $flags;

# save terminal settings
$stty = `stty -g`;

my $pid = open($fp, "$console|") or
dodie "Can't open console $console";

Expand All @@ -1368,6 +1372,9 @@ sub close_console {

print "closing!\n";
close($fp);

# restore terminal settings
system("stty $stty");
}

sub start_monitor {
Expand Down

0 comments on commit 9884278

Please sign in to comment.