mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drivers/tty: Don't hangup shared ttys
@ 2013-06-11 23:03 Stéphane Marchesin
  2013-06-11 23:15 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Stéphane Marchesin @ 2013-06-11 23:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, jslaby, olof, Stéphane Marchesin

When quickly restarting X servers, we can run into a situation where
one X server quits while another one starts on the same tty. For a
while, two X servers share the tty, and when the old X server
eventually quits, the tty layer hangs up the tty, which among other
things stubs out the tty's ioctl functions. Later on, the new X
server (which shares the tty functions) tries to call some ioctls
on the tty and fails because they have been replaced with the hungup
versions. This in turn causes the new X server to abort.

This patch checks the tty->count to make sure we're the last
consumer before hanging up a tty.

Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
---
 drivers/tty/tty_io.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 6464029..62a0f02 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -619,6 +619,9 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)
 	if (!tty)
 		return;
 
+	/* Don't hangup if there are other users */
+	if (tty->count > 1)
+		return;
 
 	spin_lock(&redirect_lock);
 	if (redirect && file_tty(redirect) == tty) {
-- 
1.8.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-06-12  0:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-11 23:03 [PATCH] drivers/tty: Don't hangup shared ttys Stéphane Marchesin
2013-06-11 23:15 ` Greg KH
2013-06-11 23:19   ` Stéphane Marchesin
2013-06-12  0:05     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome