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.
This commit is contained in:
Drew Stratford 2019-10-31 01:21:09 +13:00 committed by Andreas Kling
parent 378480e8e4
commit 058c8337df
Notes: sideshowbarker 2024-07-19 11:30:02 +09:00

View File

@ -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);