cttyhack/tty/initramfs problem (take a number)

Denys Vlasenko vda.linux at googlemail.com
Sat Dec 5 04:14:47 UTC 2009


On Sat, Dec 5, 2009 at 4:57 AM, Ersin Akinci <ersin.akinci at gmail.com> wrote:
>> If you think you know better, why do you ask?
>>
>> http://www.catb.org/~esr/faqs/smart-questions.html
>
> Excuse me, I think you've misunderstood my question.  I will rephrase
> it to make it clearer.
>
> I'm trying to start the shell over a virtual tty in a minimal
> initramfs + busybox environment without any login or user account
> tools (no getty, login, etc.)  When my init script runs "/bin/sh" at
> the end, it works but without job control because apparently it's not
> using a "normal" tty.  So, my goal is to get the shell to use a
> "normal" tty rather than /dev/console or anything else.  Now, AFAIK
> there are two steps involved, neither of which I understand very well
> and both of which I need some advice on:
>
> 1) Generating the correct tty device nodes
> 2) Making the shell use those device nodes
>
> You suggested that I create /dev/tty1, but as I understand it this is
> using the "old", non-Unix98/devpts method,

No, it is NOT the "old" method. It is the correct method.
Where did you get this strange idea that all ttys
should be ptys?

> which in my first e-mail I
> said I wasn't using.  When I mount devpts, however, /dev/pts is
> completely empty.  I thought that maybe invoking getty magically
> generates nodes in /dev/pts on demand, but you said that wasn't the
> case.

/dev/pty is for PSEUDO ttys, like those created by telnet, ssh, xterm etc.
Forget about /dev/pty, is it irrelevant to your situation.

> So my question is how do I generate the proper /dev/pts nodes, and
> then how do I get my shell to use them?  Your solution is perfectly
> fine, except that I'm not using the /dev/ttyXX naming scheme with my
> kernel or libc libraries.  Moreover, if you had read my last e-mail
> you would notice that I tried your suggestion and that I'm still
> getting the job control error.

You did not specify that you were still using cttyhack.
IOW, you did not provide complete info, making it
necessary to guess what do you actually do on your system.

> #!/bin/sh
>
> export PATH="/usr/bin:/usr/sbin:/bin:/sbin"
>
> mount -t proc proc /proc
> mount -t sysfs sysfs /sys
> mount -t devpts none /dev/pts -o gid=4,mode=620
>
> echo 0 > /proc/sys/kernel/printk
>
> echo
> echo "Welcome to 420CDT Linux!"
> echo
> exec cttyhack sh

Does /dev/tty1 exist? If yes, can you strace  cttyhack sh?
And also try:

exec </dev/tty1 >/dev/tty1 2>/dev/tty1
exec sh

--
vda


More information about the busybox mailing list