From abde919bbd83548e7a2d4d88985c8959115be4d2 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Wed, 19 Sep 2012 21:13:48 +0200 Subject: [PATCH] pty: set VERASE character to backspace during setup Some crazy guy decided to set VERASE to DEL by default in the kernel. So when starting an application which does not initialize the terminal on startup, they may not notice that we actually send BACKSPACE as erase-character (like /bin/login). Therefore, initialize VERASE to 010 so everyone is happy. Thanks to Etam for reporting this! Signed-off-by: David Herrmann --- src/pty.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pty.c b/src/pty.c index b20a3f8..98c9283 100644 --- a/src/pty.c +++ b/src/pty.c @@ -184,6 +184,7 @@ static void setup_child(int master, struct winsize *ws) pid_t pid; char slave_name[128]; int slave = -1; + struct termios attr; /* The child should not inherit our signal mask. */ sigemptyset(&sigset); @@ -223,6 +224,21 @@ static void setup_child(int master, struct winsize *ws) goto err_out; } + /* get terminal attributes */ + if (tcgetattr(slave, &attr) < 0) { + log_err("cannot get terminal attributes: %m"); + goto err_out; + } + + /* erase character should be normal backspace */ + attr.c_cc[VERASE] = 010; + + /* set changed terminal attributes */ + if (tcsetattr(slave, TCSANOW, &attr) < 0) { + log_warn("cannot set terminal attributes: %m"); + goto err_out; + } + if (ws) { ret = ioctl(slave, TIOCSWINSZ, ws); if (ret)