lkml.org 
[lkml]   [2008]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 0/3] SIGWINCH problem with terminal apps still alive
Hello,

I am sending sligtly corrected patch.
In case of ioctl(,TIOCSWINSZ,) on pty side we should send signal to
master side too. I've tested it on modified unix putty version
and it works properly.

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

Maybe we could optimize code more and not call
get_pid() and put_pid() if they are not needed - in case
where there is no master/slave pair.

Regards

--
Adam Tlałka mailto:atlka@pg.gda.pl ^v^ ^v^ ^v^
System & Network Administration Group - - - ~~~~~~
Computer Center, Gdańsk University of Technology, Poland
--- tty_io_orig.c 2008-10-10 05:37:30.000000000 +0200
+++ tty_io.c 2008-10-14 14:28:50.000000000 +0200
@@ -2522,29 +2522,33 @@ int tty_do_resize(struct tty_struct *tty
struct pid *pgrp, *rpgrp;
unsigned long flags;

- /* For a PTY we need to lock the tty side */
+ /* in case of resize ioctl on slave */
+ if ((tty == real_tty)
+ && tty->driver->type == TTY_DRIVER_TYPE_PTY)
+ tty = tty->link;
+
+ /* for a PTY we need to lock the tty side */
mutex_lock(&real_tty->termios_mutex);
- if (!memcmp(ws, &tty->winsize, sizeof(*ws)))
- goto done;
- /* 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);
- pgrp = get_pid(tty->pgrp);
- rpgrp = get_pid(real_tty->pgrp);
- spin_unlock_irqrestore(&tty->ctrl_lock, flags);
-
- if (pgrp)
- kill_pgrp(pgrp, SIGWINCH, 1);
- if (rpgrp != pgrp && rpgrp)
- kill_pgrp(rpgrp, SIGWINCH, 1);
-
- put_pid(pgrp);
- put_pid(rpgrp);
-
- tty->winsize = *ws;
+ flags = memcmp(ws, &real_tty->winsize, sizeof(*ws));
real_tty->winsize = *ws;
-done:
mutex_unlock(&real_tty->termios_mutex);
+ if (flags){
+ /* 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);
+ pgrp = get_pid(tty->pgrp);
+ rpgrp = get_pid(real_tty->pgrp);
+ spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+
+ if (pgrp)
+ kill_pgrp(pgrp, SIGWINCH, 1);
+ if (rpgrp != pgrp && rpgrp)
+ kill_pgrp(rpgrp, SIGWINCH, 1);
+
+ put_pid(pgrp);
+ put_pid(rpgrp);
+ }
+
return 0;
}

@@ -2996,7 +3000,7 @@ long tty_ioctl(struct file *file, unsign
case TIOCSTI:
return tiocsti(tty, p);
case TIOCGWINSZ:
- return tiocgwinsz(tty, p);
+ return tiocgwinsz(real_tty, p);
case TIOCSWINSZ:
return tiocswinsz(tty, real_tty, p);
case TIOCCONS:
\
 
 \ /
  Last update: 2008-10-14 14:55    [W:0.076 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site