Re: [PATCH] kdesu broken

From: Aneesh Kumar K.V
Date: Mon Jul 27 2009 - 12:14:45 EST


On Tue, Jul 28, 2009 at 12:04:42AM +0900, OGAWA Hirofumi wrote:
> Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> writes:
>
> >> > + set_bit(TTY_EOFPENDING, &pair->flags);
> >> > + set_bit(TTY_OTHER_CLOSED, &pair->flags);
> >> > + spin_unlock_irqrestore(&pair->buf.lock, flags);
> >>
> >> tty_flip_buffer_push() or something?
> >>
> >> > + wake_up_interruptible(&pair->read_wait);
> >> > + wake_up_interruptible(&pair->write_wait);
> >>
> >> It seems, this sets TTY_EOFPENDING, but if flush_to_ldisc() was done
> >> already here, anybody doesn't set TTY_EOF for master.
> >
> > Does putting a tty_flip_buffer_push() at that point fix it. I had thought
> > I could remove it but you are right that creates a situation where EOF
> > may never get set.
>
> With this patch, test program seems to work.
>
> It seems "done = 0" hunk was needed for correct "done".
>
> Thanks.
>
>
> Signed-off-by: OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>
> ---
>
> drivers/char/pty.c | 1 +
> drivers/char/tty_buffer.c | 4 +---
> 2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff -puN drivers/char/pty.c~pty-fixes4-fix drivers/char/pty.c
> --- linux-2.6/drivers/char/pty.c~pty-fixes4-fix 2009-07-27 23:56:27.000000000 +0900
> +++ linux-2.6-hirofumi/drivers/char/pty.c 2009-07-27 23:56:40.000000000 +0900
> @@ -64,6 +64,7 @@ static void pty_close(struct tty_struct
> set_bit(TTY_EOFPENDING, &pair->flags);
> set_bit(TTY_OTHER_CLOSED, &pair->flags);
> spin_unlock_irqrestore(&pair->buf.lock, flags);
> + tty_flip_buffer_push(pair);
> wake_up_interruptible(&pair->read_wait);
> wake_up_interruptible(&pair->write_wait);
> if (tty->driver->subtype == PTY_TYPE_MASTER) {
> diff -puN drivers/char/tty_buffer.c~pty-fixes4-fix drivers/char/tty_buffer.c
> --- linux-2.6/drivers/char/tty_buffer.c~pty-fixes4-fix 2009-07-27 23:57:27.000000000 +0900
> +++ linux-2.6-hirofumi/drivers/char/tty_buffer.c 2009-07-27 23:57:30.000000000 +0900
> @@ -443,10 +443,8 @@ static void flush_to_ldisc(struct work_s
> done = 0;
> break;
> }
> - if (count > tty->receive_room) {
> + if (count > tty->receive_room)
> count = tty->receive_room;
> - done = 0;
> - }
> char_buf = head->char_buf_ptr + head->read;
> flag_buf = head->flag_buf_ptr + head->read;
> head->read += count;
> _


I still have the "compile in emacs" bug. So this patch along with
http://article.gmane.org/gmane.linux.kernel/869824 doesn't fix the
bug for me.

-aneesh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/