[PATCH 0/1] SIGWINCH problem with terminal apps still alive

From: Adam TlaÅka
Date: Thu Oct 09 2008 - 21:14:37 EST


Welcome,

now we have 2.6.26.6 kernel and still terminal resize leads to
undesired effects. It is very inconvenient to wait for 2.6.27 for
corrections.

As Alan Cox previously said mutexes generally work but as we can
observe in case of kill_pgrp() call inside mutex lock we got
race because of rescheduling so lock is not working here.
Rearanging code so the variable change is placed before kill_pgrp()
call removes mentioned race situaction.

Signed-off-by: Adam Tla/lka <atlka@xxxxxxxxx>

I strongly suggest to patch actual 2.6.26.x kernel to remove this very
nasty pts behaviour.

Regards

--
Adam TlaÅka mailto:atlka@xxxxxxxxx ^v^ ^v^ ^v^
--- drivers/char/tty_io_orig.c 2008-10-10 02:30:18.000000000 +0200
+++ drivers/char/tty_io.c 2008-10-10 02:33:38.000000000 +0200
@@ -3014,6 +3014,9 @@ static int tiocswinsz(struct tty_struct
}
}
#endif
+ tty->winsize = tmp_ws;
+ real_tty->winsize = tmp_ws;
+
/* Get the PID values and reference them so we can
avoid holding the tty ctrl lock while sending signals */
spin_lock_irqsave(&tty->ctrl_lock, flags);
@@ -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;
--- drivers/char/vt_orig.c 2008-10-10 02:12:40.000000000 +0200
+++ drivers/char/vt.c 2008-10-10 02:31:28.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);
}