public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Newall <davidn@davidnewall.com>
To: Willy Tarreau <w@1wt.eu>
Cc: Chris Frey <cdfrey@foursquare.net>,
	Joe Peterson <joe@skyrush.com>,
	Vegard Nossum <vegard.nossum@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: Visible Ctrl-C in latest kernels
Date: Tue, 26 Aug 2008 03:07:06 +0930	[thread overview]
Message-ID: <48B2EDC2.1020608@davidnewall.com> (raw)
In-Reply-To: <20080825122024.GA19337@1wt.eu>

Willy Tarreau wrote:
> I would not be surprized that it is what has caused delays for Ctrl-C
> to take effect for some of us. As discussed in another thread on the
> subject, the problem was relatively recent and not easy to reproduce.
>   

I don't think so.  Joe Peterson raised A line of enquiry, which looked
quite promising to me, in
http://marc.info/?l=linux-kernel&m=121502197008293.  He observed weird
behaviour with pgrp, and that doesn't seem to have been explored
adequately.  I think it's worth highlighting that the code which sends
the signal is the following snippet, from n_tty.c:

    if (tty->pgrp)
            kill_pgrp(tty->pgrp, signal, 1);


I wonder if pgrp has a value different than we expect?


> Now we have a patch to try to revert if/when we finally get a reproducible
> case.

I had an idea; it didn't work out as I expected, but it did produce a
result that I can't immediately explain; and it might be relevant.  The
following program, when executed in background (./testprogram &) stops
at tcsetpgrp(), which is fine; and if then continued (fg), it is immune
to the interrupt, quit and suspend keys.  However, it is not immune to
those keys if executed in foreground (./testprogram).  As said, I can't
immediately explain this, and it seems like it might be important...

#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>

main() {
        int i;
        pid_t pid = getpid();
        pid_t ppid = getppid();
        int tty = open("/dev/tty", 0);
        if (tty == -1) {
                perror("/dev/tty");
                exit(1);
        }
        printf("pid %d (pgrp %d), ppid %d (pgrp %d), pgrp %d\n", pid, getpgid(pid), ppid, getpgid(ppid), tcgetpgrp(tty));

        if (tcsetpgrp(tty, ppid) == -1) {
                perror("tcsetpgrp");
                exit(2);
        }

        for (i = 0; i < 5; i++) {
                sleep(1);
                write(1, ".", 1);
        }
        sleep(1);
        write(1, "\n", 1);

        return 0;
}



  parent reply	other threads:[~2008-08-25 17:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-22 20:15 Visible Ctrl-C in latest kernels Chris Frey
2008-08-23  9:53 ` Vegard Nossum
2008-08-23 17:52   ` Joe Peterson
2008-08-24  1:02     ` Chris Frey
2008-08-25 12:20       ` Willy Tarreau
2008-08-25 14:00         ` Joe Peterson
2008-08-25 14:13           ` Willy Tarreau
2008-08-25 14:29             ` Joe Peterson
2008-08-25 17:37         ` David Newall [this message]
2008-08-25 18:03           ` Joe Peterson
2008-08-26  1:08             ` Joe Peterson
2008-08-26  7:40               ` David Newall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48B2EDC2.1020608@davidnewall.com \
    --to=davidn@davidnewall.com \
    --cc=cdfrey@foursquare.net \
    --cc=joe@skyrush.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vegard.nossum@gmail.com \
    --cc=w@1wt.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox