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:-)

2
  • 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. Commented Jul 13, 2019 at 4: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. Commented Jul 13, 2019 at 6:07

3 Answers 3

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.

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.

2
  • where do you type this? Commented Nov 22, 2023 at 22:25
  • You would place this in your init script Commented Nov 12, 2024 at 6:08
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 
2
  • 1
    What is "even shorter" than what?  And what does the user do with these commands? Commented Feb 14, 2024 at 15:42
  • You would place this in your init script @G-ManSays'ReinstateMonica Commented Nov 12, 2024 at 6:08

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.