public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Walrond <andrew@walrond.org>
To: util-linux@vger.kernel.org
Subject: Re: agetty problem after upgrading v2.19.1 -> v2.20.1
Date: Sun, 4 Dec 2011 12:05:49 +0000	[thread overview]
Message-ID: <20111204120548.GA23245@golden.localdomain> (raw)
In-Reply-To: <20111203171658.GA9780@golden.localdomain>

After reading the following from Andries Brouwer's excellent "The Linux Kernel",
     http://www.win.tue.nl/~aeb/linux/lk/lk-10.html#ss10.3

>
> How does one get a controlling terminal? Nobody knows, this is a great mystery.
>
> The System V approach is that the first tty opened by the process becomes its controlling tty.
>
> The BSD approach is that one has to explicitly call
>
>    ioctl(fd, TIOCSCTTY, ...);
>
> to get a controlling tty.
>
> Linux tries to be compatible with both, as always, and this results in a very obscure complex of conditions. Roughly:
>
> The TIOCSCTTY ioctl will give us a controlling tty, provided that (i) the current process is a session leader, and (ii) it does not yet have a controlling tty, and (iii) maybe the tty should not already control some other session; if it does it is an error if we aren't root, or we steal the tty if we are all-powerful.
>
> Opening some terminal will give us a controlling tty, provided that (i) the current process is a session leader, and (ii) it does not yet have a controlling tty, and (iii) the tty does not already control some other session, and (iv) the open did not have the O_NOCTTY flag, and (v) the tty is not the foreground VT, and (vi) the tty is not the console, and (vii) maybe the tty should not be master or slave pty." 
>

it seems obvious that agetty is always going to fail unless it has already been made a session leader by the caller. Indeed, modifying init to call setsid() before exec'ing agetty makes everything work again.
What's not so obvious to me is whether agetty should always expect this, or become a session leader of it's own accord.

Andrew Walrond

  reply	other threads:[~2011-12-04 12:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-03 17:16 agetty problem after upgrading v2.19.1 -> v2.20.1 Andrew Walrond
2011-12-04 12:05 ` Andrew Walrond [this message]
2011-12-08 12:04   ` Karel Zak
2011-12-08 14:52     ` Andrew Walrond

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=20111204120548.GA23245@golden.localdomain \
    --to=andrew@walrond.org \
    --cc=util-linux@vger.kernel.org \
    /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