简体   繁体   English

/bin/sh: 无法访问 tty; 作业控制已关闭

[英]/bin/sh: can't access tty; job control turned off

I have been following the commands from the book "Mastering embedded linux programming" by Chris Simmonds.我一直在遵循 Chris Simmonds 的“掌握嵌入式 linux 编程”一书中的命令。 I have created the toolchain, kernel zImage and busybox file system.我创建了工具链 kernel zImage 和 busybox 文件系统。 When I combine these together to run on QEMU, It should display a root shell prompt.当我将这些组合在一起在 QEMU 上运行时,它应该显示一个根 shell 提示符。

When I run the command, I get the following.当我运行命令时,我得到以下信息。

/bin/sh: can't access tty; job control turned off 
input: ImExPS/2 Generic Explorer Mouse as /devices/platform/amba/amba:fpga/10007000.kmi/serio1/input/input2 

When I press enter, I am able to see the root shell prompt and I am able to execute simple shell commands.当我按下回车键时,我能够看到根 shell 提示,并且我能够执行简单的 shell 命令。

However, when I press exit, I get the following error.但是,当我按退出时,出现以下错误。

Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000

CPU: 0 PID: 1 Comm: sh Not tainted 4.9.13 #1
Hardware name: ARM-Versatile (Device Tree Support)
[<c001b5a4>] (unwind_backtrace) from [<c0018860>] (show_stack+0x10/0x14)
[<c0018860>] (show_stack) from [<c00737f4>] (panic+0xb8/0x230)
[<c00737f4>] (panic) from [<c0024e24>] (do_exit+0x8e8/0x938)
[<c0024e24>] (do_exit) from [<c0025cf8>] (do_group_exit+0x38/0xb4)
[<c0025cf8>] (do_group_exit) from [<c0025d84>] (__wake_up_parent+0x0/0x18)
---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000

How do I resolve this我该如何解决这个问题

EDIT:编辑:

The following is the QEMU command that I ran以下是我运行的 QEMU 命令

QEMU_AUDIO_DRV=none \qemu-system-arm 
-m 256M -nographic 
-M versatilepb 
-kernel ~/linux-4.9.13/arch/arm/boot/zImage 
\-append "console=ttyAMA0,115200 rdinit=/bin/sh" 
-dtb ~/linux-4.9.13/arch/arm/boot/dts/versatile-pb.dtb 
-initrd ~/busybox/initramfs.cpio.gz

(You don't say what your QEMU command line is.) (你没有说你的 QEMU 命令行是什么。)

These error messages generally are what you should expect if you tell the kernel to run /bin/sh directly as its process 1 (eg with "init=/bin/sh" on the kernel command line).如果您告诉 kernel 直接将 /bin/sh 作为其进程 1 运行(例如,在 kernel 命令行上使用“init=/bin/sh”),这些错误消息通常是您应该预料到的。 First the shell complains that it doesn't have a tty, but it can continue anyway with some facilities disabled.首先,shell 抱怨它没有 tty,但它仍然可以在禁用某些设施的情况下继续。 Then, when you eventually tell the shell to exit, because the shell itself is process 1 the kernel complains.然后,当您最终告诉 shell 退出时,因为 shell 本身是进程 1,kernel 会抱怨。 (Usually process 1 is supposed to be an "init" program, which runs forever and deals with starting other processes in the system. If "init" ever dies the kernel has nothing else it can do.) (通常进程 1 应该是一个“init”程序,它永远运行并处理启动系统中的其他进程。如果“init”死了,kernel 将无能为力。)

If you were intending to run /bin/sh as your process 1, then this is all normal.如果您打算将 /bin/sh 作为进程 1 运行,那么这一切都很正常。 If you didn't want to do that, then you have an issue with either your root filesystem or with your command line which means that it isn't properly starting an /sbin/init in the guest, and you should look at why.如果您不想这样做,那么您的根文件系统或命令行有问题,这意味着它没有在客户机中正确启动 /sbin/init,您应该看看原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM