Skip to content

Commit

Permalink
Shell: Properly set and restore termios settings.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DrewStratford authored and awesomekling committed Oct 30, 2019
1 parent 378480e commit 058c833
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Shell/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 058c833

Please sign in to comment.