Subject: running getty
To: None <tech-userlevel@netbsd.org>
From: None <erh@swapsimple.com>
List: tech-userlevel
Date: 11/02/2005 13:23:32
I recently tried doing a few things on my machine in single user
mode and got annoyed that I could only have a single screen active.
Running "/etc/rc.d/wscons start" got the additional screens configured.
Then, since the man page says it'll go open the device you tell it to,
I figured "/usr/libexec/getty vt200 ttyE1" would get me up and running.
It didn't. Instead, it just displayed the login on the _current_ tty.
A quick ktrace showed that both setsid() and the ioctl(TIOCSCTTY) were
failing (EPERM for both). (called from within login_tty() in libutil)
For setsid() I figured well, whatever: the shell sets things
up so the getty process is already the process group leader so doing it
twice is harmless.
The shell then, of course, sets the controlling tty so trying to set
it again with TIOCSCTTY fails. That makes sense. So I decided to undo
that with TIOCNOTTY. That ioctl() call appeared to work, but the
call to TIOCSCTTY _still_ failed. Why?
I added a bit of code to fork() just before login_tty() if /dev/tty
can't be opened, which is only possible if there is a controlling
terminal. This works, but it seems like overkill to fork an entire
new process.
eric