/* Update the termios variables and send the neccessary signals to peform a terminal resize correctly  */
int tty_do_resize(struct tty_struct *tty, struct winsize *ws)
/* Update the termios variables and send the neccessary signals to peform a terminal resize correctly  */
int tty_do_resize(struct tty_struct *tty, struct winsize *ws)
{
	struct pid *pgrp;
	unsigned long flags;
	mutex_lock(&tty->termios_mutex);
	if (!memcmp(ws, &tty->winsize, sizeof(*ws)))
		goto done;
	spin_lock_irqsave(&tty->ctrl_lock, flags);
	pgrp = get_pid(tty->pgrp);
	spin_unlock_irqrestore(&tty->ctrl_lock, flags);
	if (pgrp)
		kill_pgrp(pgrp, SIGWINCH, 1);
	put_pid(pgrp);
	tty->winsize = *ws;
done:
	mutex_unlock(&tty->termios_mutex);
	return 0;
}