diff options
author | Josh Poimboeuf <jpoimboe@redhat.com> | 2015-01-27 13:10:04 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2015-01-27 17:44:57 -0500 |
commit | 988427829bcd230c78106d28dbfa85d45d182909 (patch) | |
tree | 9860c7341452a0adbad74bf6951f10712233d33d /tools/testing/ktest/ktest.pl | |
parent | b53486e08377506179e5da0abe8b960dba5c483a (diff) |
ktest: Restore tty settings after closing console
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>
Diffstat (limited to 'tools/testing/ktest/ktest.pl')
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 27273c228d92..1dae000f79f8 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
@@ -178,6 +178,7 @@ my $checkout; | |||
178 | my $localversion; | 178 | my $localversion; |
179 | my $iteration = 0; | 179 | my $iteration = 0; |
180 | my $successes = 0; | 180 | my $successes = 0; |
181 | my $stty; | ||
181 | 182 | ||
182 | my $bisect_good; | 183 | my $bisect_good; |
183 | my $bisect_bad; | 184 | my $bisect_bad; |
@@ -1349,6 +1350,9 @@ sub open_console { | |||
1349 | 1350 | ||
1350 | my $flags; | 1351 | my $flags; |
1351 | 1352 | ||
1353 | # save terminal settings | ||
1354 | $stty = `stty -g`; | ||
1355 | |||
1352 | my $pid = open($fp, "$console|") or | 1356 | my $pid = open($fp, "$console|") or |
1353 | dodie "Can't open console $console"; | 1357 | dodie "Can't open console $console"; |
1354 | 1358 | ||
@@ -1368,6 +1372,9 @@ sub close_console { | |||
1368 | 1372 | ||
1369 | print "closing!\n"; | 1373 | print "closing!\n"; |
1370 | close($fp); | 1374 | close($fp); |
1375 | |||
1376 | # restore terminal settings | ||
1377 | system("stty $stty"); | ||
1371 | } | 1378 | } |
1372 | 1379 | ||
1373 | sub start_monitor { | 1380 | sub start_monitor { |