tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: How Unix manages processes in userland

On Fri, Dec 06, 2013 at 07:01:28AM +0700, Robert Elz wrote:
> There is no reason that management of daemons, or for that mater,
> logins on ttys, needs to be done by process 1.   tty login management
> isn't done that way because it has to be, but because it always has been
> (and it gives init some work to do, something less morbid than just
> being a graveyard for orphans.)

One thing that has to be done for ttys is to reset the permissions when
the user logs out, and tidy up the utmp file.
IIRC on sysv this is usually done writing a message to init (via a pipe)
giving it the pid and tty name.

We used to end up with /dev entries for ttys that were just minor numbers
on the protocol stack's device (enough STREAMS modules were pushed).
If all the processes closed their terminal, the minor number could get
reused [1], but the tty /dev entry would still be present - and then
programs like wall(1) would write into randon connections!

One solution was to use fattach() (like mount) the cloned tty device
onto a dummy entry in /dev and then change the permissions.
This all 'fell apart' on last close.


[1] but not by the same process - it wasn't allowed to read/write
the major/minor pair that used to be its controlling terminal!

David Laight:

Home | Main Index | Thread Index | Old Index