mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/0] SIGWINCH problem with terminal apps
@ 2008-10-06 12:07 Adam Tlałka
  2008-10-06 13:13 ` Alan Cox
  0 siblings, 1 reply; 12+ messages in thread
From: Adam Tlałka @ 2008-10-06 12:07 UTC (permalink / raw)
  To: linux-kernel; +Cc: torvalds

[-- Attachment #1: Type: text/plain, Size: 1561 bytes --]

Welcome,

I've observed then very often a X11 terminal app is not getting proper
window sizes afer terminal resize operation. This could be seen with
mc, jed, vim or other curses and not curses aware apps.

I wrote a simple program which just does nothing but uses SIGWINCH
handler so I can observe values reported by ioctl(1,TIOCGWINS,&ws) call
inside my signal handler. What is interesting that from time to time it
obtain unchanged values. It means values which were valid just before
terminal resize.

In drivers/char/vt.c and drivers/char/tty_io.c variables
vc->vc_tty->winsize and tty->winsize , real_tty->winsize are updated
after kill_pgrp(pgrp, SIGWINCH, 1) calls. I am not very familiar with
mutex design and how it corresponds to kill_pgrp() kernel function but
it seems that locking is not working here as we expect. An app can read
tty winsize data through ioctl() call in SIGWINCH handler and obtain
uchanged values.

So as a quick solution I made patches which move mentioned updates
before kill_pgrp() calls. As I tested modified kernel there is no
observed effect now. So I send patchs.

There are some places where kill_pgrp() call is used and some variable
is changed after it. It should be considered if this code is always
working properly or some race scheduler condition exists.

Signed-off-by: Adam Tla/lka <atlka@pg.gda.pl>

-- 
Adam Tlałka       mailto:atlka@pg.gda.pl    ^v^ ^v^ ^v^
System  & Network Administration Group       - - - ~~~~~~
Computer Center, Gdańsk University of Technology, Poland

[-- Attachment #2: 2.6.26.2_tty_io.patch --]
[-- Type: text/x-patch, Size: 624 bytes --]

--- drivers/char/tty_io_orig.c	2008-10-06 11:03:39.000000000 +0200
+++ drivers/char/tty_io.c	2008-10-06 11:20:54.000000000 +0200
@@ -3021,6 +3021,9 @@ static int tiocswinsz(struct tty_struct 
 	rpgrp = get_pid(real_tty->pgrp);
 	spin_unlock_irqrestore(&tty->ctrl_lock, flags);
 
+	tty->winsize = tmp_ws;
+	real_tty->winsize = tmp_ws;
+
 	if (pgrp)
 		kill_pgrp(pgrp, SIGWINCH, 1);
 	if (rpgrp != pgrp && rpgrp)
@@ -3028,9 +3031,6 @@ static int tiocswinsz(struct tty_struct 
 
 	put_pid(pgrp);
 	put_pid(rpgrp);
-
-	tty->winsize = tmp_ws;
-	real_tty->winsize = tmp_ws;
 done:
 	mutex_unlock(&tty->termios_mutex);
 	return 0;

[-- Attachment #3: 2.6.26.2_vt.patch --]
[-- Type: text/x-patch, Size: 493 bytes --]

--- drivers/char/vt_orig.c	2008-10-06 11:01:26.000000000 +0200
+++ drivers/char/vt.c	2008-10-06 11:59:48.000000000 +0200
@@ -921,11 +921,11 @@ int vc_resize(struct vc_data *vc, unsign
 		if ((ws.ws_row != cws->ws_row || ws.ws_col != cws->ws_col))
 			pgrp = get_pid(vc->vc_tty->pgrp);
 		spin_unlock_irq(&vc->vc_tty->ctrl_lock);
+		*cws = ws;
 		if (pgrp) {
 			kill_pgrp(vc->vc_tty->pgrp, SIGWINCH, 1);
 			put_pid(pgrp);
 		}
-		*cws = ws;
 		mutex_unlock(&vc->vc_tty->termios_mutex);
 	}
 

^ permalink raw reply	[flat|nested] 12+ messages in thread
[parent not found: <bjXel-4CU-17@gated-at.bofh.it>]

end of thread, other threads:[~2008-10-11 17:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-06 12:07 [PATCH 0/0] SIGWINCH problem with terminal apps Adam Tlałka
2008-10-06 13:13 ` Alan Cox
2008-10-06 18:28   ` Adam Tlałka
2008-10-06 22:14     ` Alan Cox
2008-10-07 20:28       ` Adam Tlałka
2008-10-10  1:12         ` [PATCH 0/1] SIGWINCH problem with terminal apps still alive Adam Tlałka
2008-10-10  3:32           ` Adam Tlałka
2008-10-10  9:29           ` Alan Cox
2008-10-10 10:35             ` Adam Tlałka
2008-10-10 11:56               ` Adam Tlałka
     [not found] <bjXel-4CU-17@gated-at.bofh.it>
     [not found] ` <bjYap-5Q0-25@gated-at.bofh.it>
     [not found]   ` <bk30i-3Gx-1@gated-at.bofh.it>
     [not found]     ` <bk6AV-8ms-7@gated-at.bofh.it>
     [not found]       ` <bkrvO-1HF-49@gated-at.bofh.it>
     [not found]         ` <blePJ-6rI-3@gated-at.bofh.it>
     [not found]           ` <blmDC-7ZU-7@gated-at.bofh.it>
2008-10-11 14:04             ` Bodo Eggert
2008-10-11 17:58               ` Alan Cox

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

all inboxes | Powered by JetHome®