0

i'm testing my custom initramfs now, but everytime the log there will have the

"can't access tty; job control turned off".

The /dev in initramfs has four files: null, sda1, ttyS0. The kernel parameter is 'console=ttyS0'.

Also, i test ctrl+c, it works fine.So how could this problem heppen? In busybox documentation,

Why do I keep getting "sh: can't access tty; job control turned off" errors? Why doesn't Control-C work within my shell? This isn't really a uClibc question, but I'll answer it here anyways. Job control will be turned off since your shell can not obtain a controlling terminal. This typically happens when you run your shell on /dev/console. The kernel will not provide a controlling terminal on the /dev/console device. Your should run your shell on a normal tty such as tty1 or ttyS0 and everything will work perfectly. If you REALLY want your shell to run on /dev/console, then you can hack your kernel (if you are into that sortof thing) by changing drivers/char/tty_io.c to change the lines where it sets "noctty = 1;" to instead set it to "0". I recommend you instead run your shell on a real console...

I type tty and it gives me /dev/console instead of /dev/ttyS0.

So, that's all information about this problem, hope some one can help me out:-)

  • are you running busybox inside your initramfs? then look for "cttyhack". Maybe do what it's doing if your building your own stuff. You can also run script /dev/null, or create a pty by other means. –  Jul 13 '19 at 04:39
  • 1
    here you go. The //config: comments tell you everything you need to know, including a workaround. You can copy-paste it into an answer, something I cannot do on a phone. –  Jul 13 '19 at 06:07

3 Answers3

0

As commented by pizdelect, here is the solution: https://raw.githubusercontent.com/brgl/busybox/master/shell/cttyhack.c.

For me, I simply use ::respawn:/bin/cttyhack /bin/sh.

Edward
  • 2,509
0

Recompiling cttyhack.c is too troublesome, just wrap /bin/sh in a shell:

setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'

will work.

0

Here's a shorter solution:

exec setsid sh </dev/tty1 >/dev/tty1 2>&1

If you just want to run agetty, then this is even shorter:

exec setsid agetty tty1 </dev/tty1 >/dev/tty1 2>&1