Просмотр исходного кода

tty SIGINT、SIGTSTP 信号实现

linzhenxing 3 лет назад
Родитель
Сommit
75725bb8d1
1 измененных файлов с 21 добавлено и 2 удалено
  1. 21 2
      components/drivers/tty/n_tty.c

+ 21 - 2
components/drivers/tty/n_tty.c

@@ -528,13 +528,32 @@ static void eraser(unsigned char c, struct tty_struct *tty)
  *
  *  Locking: ctrl_lock
  */
-
+extern struct termios old_stdin_termios;
 static void __isig(int sig, struct tty_struct *tty)
 {
     struct rt_lwp *lwp = tty->foreground;
+    struct tty_ldisc *ld = RT_NULL;
+    struct termios *new_termios = &old_stdin_termios;
+
     if (lwp)
     {
-        lwp_kill(lwp_to_pid(lwp), sig);
+        if (sig == SIGTSTP)
+        {
+            tty->init_termios = *new_termios;
+            ld = tty->ldisc;
+            if (ld != RT_NULL)
+            {
+                if (ld->ops->set_termios)
+                {
+                    ld->ops->set_termios(tty, &old_stdin_termios);
+                }
+            }
+            tty->foreground = RT_NULL;  
+        }
+        else
+        {
+            lwp_kill(lwp_to_pid(lwp), sig);
+        }
     }
 }