From 69f3d39da50555811687b3c8fc65553c56c5ccc7 Mon Sep 17 00:00:00 2001 From: linzhenxing Date: Mon, 18 Jul 2022 15:20:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8E=E5=8F=B0=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B=E8=BE=93=E5=87=BA=E8=A7=A6=E5=8F=91SIGTTOU=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/tty/n_tty.c | 15 +++++++++++++++ components/drivers/tty/tty.c | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/components/drivers/tty/n_tty.c b/components/drivers/tty/n_tty.c index 5a723f0cc7..4a2652d618 100644 --- a/components/drivers/tty/n_tty.c +++ b/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 diff --git a/components/drivers/tty/tty.c b/components/drivers/tty/tty.c index 6ba733f778..cf718b4770 100644 --- a/components/drivers/tty/tty.c +++ b/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(¤t->signal, sig) || + return (tty_sigismember(¤t->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)) { -- Gitee