From 058c8337df99d32b71384981362c1a3658e93673 Mon Sep 17 00:00:00 2001 From: Drew Stratford Date: Thu, 31 Oct 2019 01:21:09 +1300 Subject: [PATCH] Shell: Properly set and restore termios settings. Previously, we did not properly restore termios settings after running built-in commands. This has been fixed by ensuring that we only change the termios settings when we are forking a child process. --- Shell/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shell/main.cpp b/Shell/main.cpp index 2dc62b0702869a..100fdfc889a043 100644 --- a/Shell/main.cpp +++ b/Shell/main.cpp @@ -634,7 +634,6 @@ static int run_command(const String& cmd) struct termios trm; tcgetattr(0, &trm); - tcsetattr(0, TCSANOW, &g.default_termios); struct SpawnedProcess { String name; @@ -730,6 +729,7 @@ static int run_command(const String& cmd) if (!child) { setpgid(0, 0); tcsetpgrp(0, getpid()); + tcsetattr(0, TCSANOW, &g.default_termios); for (auto& rewiring : subcommand.rewirings) { #ifdef SH_DEBUG dbgprintf("in %s<%d>, dup2(%d, %d)\n", argv[0], getpid(), rewiring.rewire_fd, rewiring.fd);