From: Yan Cangang <nalanzeyu@gmail.com>
To: gregkh@linuxfoundation.org, jirislaby@kernel.org
Cc: linux-kernel@vger.kernel.org, Yan Cangang <nalanzeyu@gmail.com>
Subject: [PATCH] tty:pty: move wake_up*() after tty_vhangup() in pty_close()
Date: Fri, 27 Jan 2023 15:20:17 +0800 [thread overview]
Message-ID: <20230127072017.2146403-1-nalanzeyu@gmail.com> (raw)
wake_up_interruptible() may wake up the session leader blocked on pts, at
this time the tty_signal_session_leader() in __tty_hangup() has not been
executed.
The session leader's subsequent IO on pts will fail, but the session
leader did not received SIGHUP as expected at this time.
A observed phenomenon is that when the ssh connection is disconnected, the
background jobs managed by bash did not terminate as expected. This
problem is more easily observed on low-end single-processor systems.
Signed-off-by: Yan Cangang <nalanzeyu@gmail.com>
---
drivers/tty/pty.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 07394fdaf522..fbcf2caa8fc1 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -64,8 +64,6 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
if (!tty->link)
return;
set_bit(TTY_OTHER_CLOSED, &tty->link->flags);
- wake_up_interruptible(&tty->link->read_wait);
- wake_up_interruptible(&tty->link->write_wait);
if (tty->driver->subtype == PTY_TYPE_MASTER) {
set_bit(TTY_OTHER_CLOSED, &tty->flags);
#ifdef CONFIG_UNIX98_PTYS
@@ -78,6 +76,8 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
#endif
tty_vhangup(tty->link);
}
+ wake_up_interruptible(&tty->link->read_wait);
+ wake_up_interruptible(&tty->link->write_wait);
}
/*
--
2.30.2
next reply other threads:[~2023-01-27 7:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-27 7:20 Yan Cangang [this message]
2023-01-31 9:56 ` [PATCH] tty:pty: move wake_up*() after tty_vhangup() in pty_close() Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230127072017.2146403-1-nalanzeyu@gmail.com \
--to=nalanzeyu@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox