getty

Denys Vlasenko vda.linux at googlemail.com
Sun Jan 9 22:34:48 UTC 2011


On Sunday 09 January 2011 22:35, David Henderson wrote:
> Denys Vlasenko wrote:
> > On Friday 07 January 2011 17:46, David Henderson wrote:
> >   
> >> Thanks for the reply Harald.  I tried doing that, but ran into 
> >> problems.  First, I'm using runit instead of standard init which breaks 
> >> things down into three stages (1=boot, 2=running system, 
> >> 3=shutdown|reboot).  I can successfully get to a prompt if I add "exec 
> >> /bin/bash" as the final line in stage 1,
> >>     
> >
> > What does it mean "add 'string' as the final line in stage 1"?
> > Not everyone is familiar with runit.
> >   
> Basically runit uses a three stage process to bootup, manage a live 
> system, and shutdown or reboot.  When each stage is entered, a script is 
> run (/etc/runit/1,2, or 3 depending on the stage).  The first stage is 
> only meant for one time tasks such as modprobing the initially attached 
> devices.  If I added the "exec /bin/bash" in the /etc/runit/1 script, 
> stage 2 of runit would never be entered

why?

> since after bash is loaded,  
> nothing after it in the /etc/runit/1 script gets executed.

this doesn't answer the question "why?"


"man runit" says:

"STAGE 1

runit runs /etc/runit/1 and waits for it to terminate. The system's
one time tasks are done here. /etc/runit/1 has full control of
/dev/console to be able to start an emergency shell if the one time
initialization tasks fail. If /etc/runit/1 crashes, or exits 100,
runit will skip stage 2 and enter stage 3."

so the reason why stage 2 is not entered is that stage 1
did not terminate (yet).


> >>>>>> I'm trying to get several terminals setup on a custom distro and are
> >>>>>> starting them with the following line (using runit):
> >>>>>>
> >>>>>> exec getty -i -n -t 0 -L 115200 tty1
> >>>>>>
> >>>>>> However, I still get timed out after 60 seconds and I'm being
> >>>>>> prompted for a username.
> >>>>>>             
> >
> > Can you describe in more details what you see?
> > List reader don't see your screen, you know.
> >
> >   
> using the above line, the prompt just kept repeating and timing out 
> (which I was trying to disable using the command line parameter "-t 
> 0").  As stated above, I've worked passed this issue, so this email can 
> be ignored by anyone interested in helping.

Well, option -n means "don't ask for login name", and getty
does exactly that - it doesn't ask for login name. Instead,
it does spawn /bin/login at once, and _login_ does ask for login name,
if it is not supplied with one. It also does timing out.

That's what you are seeing.

Admittedly, this getty/login siamese relationship is weird,
but it seems to be a Unix tradition.

You can run something else instead of /bin/login, using -l PROG
option.


Returning to your original question, perhaps you simply
do not need neither getty nor login.
Something like:

setsid /bin/sh </dev/tty1 >/dev//tty1 2>/dev/tty1 &

might do the trick. Sometimes you need to play more carefully
to properly get *controlling* tty:

setsid /bin/sh -c "exec /bin/sh </dev/tty1 >/dev/tty1 2>/dev/tty1" &

(You can check that you have controlling tty by running "echo TEST >/dev/tty" -
if it doesn't print "TEST" but instead you get error message, you don't have ctty)

-- 
vda


More information about the busybox mailing list