public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Peterson <joe@skyrush.com>
To: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Alan Cox <alan@redhat.com>, Alan Cox <alan@lxorguk.ukuu.org.uk>,
	David Newall <davidn@davidnewall.com>, Willy Tarreau <w@1wt.eu>,
	Harald Dunkel <harald.dunkel@t-online.de>,
	linux-kernel@vger.kernel.org, tconnors@rather.puzzling.org
Subject: tty session leader issue (was Re: 2.6.25.3: su gets stuck for root)
Date: Wed, 02 Jul 2008 13:03:56 -0500	[thread overview]
Message-ID: <486BC30C.6010705@skyrush.com> (raw)
In-Reply-To: <19f34abd0806141426o7ba13f91h6720db3609146e16@mail.gmail.com>

I have done some more investigation on this problem, and I am posting
here my results in hope that someone can point me in the right direction
for further investigation...

Summary: during the initialization of a new bash shell, the terminal
foreground process group often reverts back to that of the parent of the
bash shell (after being set *to* the bash shell pgrp by bash),
prohibiting commands like stty from being run by the init scripts.  The
result is that the execution of these commands will hang until killed,
causing the bash prompt to not appear.  Adding a delay in the script
(using sleep) increases the chance of this having time to happen.

For example, putting the following in a user's .bashrc:

sleep 2
stty -ixany

is a good way to reproduce this.  doing "su <user>" from root (note that
the fact that no password is required helps the timing) will then often
hang.  Killing -9 stty will allow the bash prompt to appear.

I have instrumented the bash source code in an attempt to see why this
is happeneing, partly because I suspected a bug in bash.  What I have
found is this:

1) bash calls tcsetpgrp() with the pgrp of the bash process (two times)
before starting to execute init scripts.  This makes sense, since bash
needs to be the session leader.  It is never called again until just
before the bash shell exits normally (at which time it returns control
to the parent).

2) During the processing of the init scripts (sometimes .bashrc, but
sometimes a system script that is processed first), calling tcgetpgrp()
shows that the pgrp has reverted back to the "su <user>" process.  It
does not appear that bash reverted it in my testing so far.  Running
stty while in the reverted state causes a hang, since bash is not the
session leader.

So here is the question: is there a way/reason the kernel would revert
the pgrp of the session leader after bash sets it?  Is there some more
instrumenting in the kernel or in bash that might reveal what is going
on?  I have heard yet another report of this happening since I added to
the thread, and I can get it to happen easily on two different machines
(a desktop and a laptop).

						Thanks, Joe


  parent reply	other threads:[~2008-07-02 18:04 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-02  1:31 2.6.25.3: su gets stuck for root Joe Peterson
2008-06-02  5:12 ` Harald Dunkel
2008-06-02  5:32   ` Willy Tarreau
2008-06-02  5:55     ` Joe Peterson
2008-06-02  8:10     ` Alan Cox
2008-06-02  9:01       ` David Newall
2008-06-02  9:20         ` Alan Cox
2008-06-02 10:16           ` Vegard Nossum
2008-06-02 10:39             ` Vegard Nossum
2008-06-02 10:52               ` Alan Cox
2008-06-02 10:57                 ` Vegard Nossum
2008-06-02 12:28                   ` Alan Cox
2008-06-02 14:31                     ` Vegard Nossum
2008-06-02 10:50             ` Alan Cox
2008-06-17 15:32               ` Joe Peterson
2008-06-02 15:26           ` Joe Peterson
2008-06-02 15:51             ` Alan Cox
2008-06-02 16:03               ` Joe Peterson
2008-06-04 14:43               ` Joe Peterson
2008-06-04 15:16                 ` Alan Cox
2008-06-04 16:52                   ` Joe Peterson
2008-06-04 17:10                     ` Alan Cox
2008-06-04 20:32                       ` Joe Peterson
2008-06-11 14:04                         ` Joe Peterson
2008-06-12 11:52                           ` Vegard Nossum
2008-06-14  1:49                             ` Joe Peterson
2008-06-14  7:45                               ` Vegard Nossum
2008-06-14 17:43                                 ` Joe Peterson
2008-06-14 20:34                                   ` Vegard Nossum
2008-06-14 20:52                                     ` Joe Peterson
2008-06-14 21:26                                       ` Vegard Nossum
2008-06-14 21:34                                         ` Joe Peterson
2008-07-02 18:03                                         ` Joe Peterson [this message]
2008-07-02 19:21                                           ` tty session leader issue (was Re: 2.6.25.3: su gets stuck for root) markus reichelt
2008-07-06 14:08                                           ` Tim Connors
2008-07-06 16:44                                             ` Alan Cox
2008-07-06 18:49                                             ` tty session leader issue [cause now known!] " Joe Peterson
2008-06-02  5:42   ` 2.6.25.3: su gets stuck for root Joe Peterson

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=486BC30C.6010705@skyrush.com \
    --to=joe@skyrush.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=alan@redhat.com \
    --cc=davidn@davidnewall.com \
    --cc=harald.dunkel@t-online.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tconnors@rather.puzzling.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