sh: can't access tty; job control turned off

Rob Landley rob at landley.net
Wed Nov 12 04:36:15 UTC 2008


On Tuesday 11 November 2008 12:55:50 Ebzzry wrote:
> Yes, I'm one of the users that got bit by this too. I searched and tried
> the suggested solutions but they all didn't work.
>
> The BusyBox FAQ at section http://busybox.net/FAQ.html#job_control
> advises the readers to run the shell on a real console? How do I do that?

There are three issues:

1) /dev/console (character device, major 5 minor 1) doesn't provide a 
controlling TTY, so you need to close the stdin/stdout/stderr attached to PID 
1 at launch and open a device yourself.

2) This assumes you've got a relevant device node, mdev -s can help here.   
(Note that if your root filesystem doesn't have a /dev/console in it before 
PID 1 gets launched, PID 1 won't have a stdin/stdout/stderr at all.  That's 
the "warning, can't open an initial console" message the kernel gives.)

3) Determining _which_ actual tty device you should be using is non-obvious, 
you can't get it by examining the /dev/console device but right after boot 
you can sometimes do:

dmesg | sed -n '/^Kernel command line:/s/.* console=\([^ ]*\).*/\1/p'

4) PID 1 has a number of signals blocked, so even if you could get it a 
controlling TTY, ctrl-z and ctrl-c and such still wouldn't necessarily work.  
You generally want your PID 1 to spawn a child process to run your shell.

I wrote the "oneit" command (posted here years ago, and in toybox) to do all 
this for you.  In theory busybox has its own thing at the bottom of the 
shells menu.  (The thing under "shells" that isn't a shell.  I haven't tried 
that implementation...)

My boot script that does this (using toybox oneit) is here:

http://landley.net/hg/firmware/file/3d2996abb6ea/sources/native/bin/qemu-setup.sh

> What I'm trying to make is just a vanilla initramfs with BusyBox in it,
> that drops me to a shell at the end of the initramfs' init.

Yup, fairly straightforward goal.

Rob



More information about the busybox mailing list