Sfoglia il codice sorgente

修复后台进程输出触发SIGTTOU的问题

linzhenxing 3 anni fa
parent
commit
69f3d39da5
2 ha cambiato i file con 17 aggiunte e 2 eliminazioni
  1. 15 0
      components/drivers/tty/n_tty.c
  2. 2 2
      components/drivers/tty/tty.c

+ 15 - 0
components/drivers/tty/n_tty.c

@@ -49,6 +49,20 @@
 #define ECHO_BLOCK      256
 #define ECHO_DISCARD_WATERMARK  RT_TTY_BUF - (ECHO_BLOCK + 32)
 
+rt_inline void tty_sigaddset(lwp_sigset_t *set, int _sig)
+{
+    unsigned long sig = _sig - 1;
+
+    if (_LWP_NSIG_WORDS == 1)
+    {
+        set->sig[0] |= 1UL << sig;
+    }
+    else
+    {
+        set->sig[sig / _LWP_NSIG_BPW] |= 1UL << (sig % _LWP_NSIG_BPW);
+    }
+}
+
 struct n_tty_data
 {
     /* producer-published */
@@ -530,6 +544,7 @@ static void __isig(int sig, struct tty_struct *tty)
                     ld->ops->set_termios(tty, &old_termios);
                 }
             }
+            tty_sigaddset(&lwp->signal_mask, SIGTTOU);
             tty->foreground = RT_NULL;  
         }
         else

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

@@ -54,7 +54,7 @@ rt_inline int tty_sigismember(lwp_sigset_t *set, int _sig)
 
 static int is_ignored(int sig)
 {
-    return (tty_sigismember(&current->signal, sig) ||
+    return (tty_sigismember(&current->signal_mask, sig) ||
         current->signal_handler[sig-1] == SIG_IGN);
 }
 
@@ -92,7 +92,7 @@ int __tty_check_change(struct tty_struct *tty, int sig)
     pgrp = current->__pgrp;
     tty_pgrp = tty->pgrp;
 
-    if (tty_pgrp && pgrp != tty->pgrp)
+    if (tty_pgrp && (pgrp != tty->pgrp))
     {
         if (is_ignored(sig))
         {