mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
Shell: Update termios settings to match line discipline.
Shell.cpp uses its own line discipline which handles echoing and line editing. Because of this we disable ICANON and ECHO so that we don't get duplicate characters or weird line editing errors. We also revert these settings just before running a command. This is so that commands may run with proper line editing and echoing.
This commit is contained in:
committed by
Andreas Kling
parent
4c35c8d7fd
commit
58f67c1ccb
@@ -634,6 +634,7 @@ static int run_command(const String& cmd)
|
||||
|
||||
struct termios trm;
|
||||
tcgetattr(0, &trm);
|
||||
tcsetattr(0, TCSANOW, &g.default_termios);
|
||||
|
||||
struct SpawnedProcess {
|
||||
String name;
|
||||
@@ -840,7 +841,12 @@ int main(int argc, char** argv)
|
||||
g.uid = getuid();
|
||||
g.sid = setsid();
|
||||
tcsetpgrp(0, getpgrp());
|
||||
tcgetattr(0, &g.termios);
|
||||
tcgetattr(0, &g.default_termios);
|
||||
g.termios = g.default_termios;
|
||||
// Because we use our own line discipline which includes echoing,
|
||||
// we disable ICANON and ECHO.
|
||||
g.termios.c_lflag &= ~(ECHO | ICANON);
|
||||
tcsetattr(0, TCSANOW, &g.termios);
|
||||
|
||||
signal(SIGINT, [](int) {
|
||||
g.was_interrupted = true;
|
||||
|
||||
Reference in New Issue
Block a user