在busybox下调试时,shell终端用ctrl+c不能终止掉正在运行的进程。
Ctrl + C首先通过 /dev/ttyS0 (/dev/console)的driver,这个serial driver直接把这个控制字符送到n_tty的driver,n_tty负责search所有的控制字符。 当 ctrl+C 按下,n_tty.c: n_tty_receive_break()–> isig(SIGINT,tty) –> kill_pg(SIGINT, tty->pgrp) signal.c: kill_pg()calls signal(SIGINT,task) 来中断每个具有groupnumber 为tty->pgrp的task.值得一提的是,只要process具有相同的group id,不管是backgroud还是foreground,都会被kill掉。
从上面的流程我们可以看到,ctrl+C是传送到/dev/ttyS0中的驱动中的。
Busybox解释:Why do I keep getting "sh: can't access tty;job control turned off" errors? Why doesn't Control-C work within myshell?
This isn't really a uClibc question, but I'll answer it here anyways. Jobcontrol will be turned off since your shell can not obtain a controllingterminal. This typically happens when you run your shell on /dev/console. Thekernel will not provide a controlling terminal on the /dev/console device. Yourshould run your shell on a normal tty such as tty1 or ttyS0 and everything willwork perfectly. If you REALLY want your shell to run on /dev/console, then you canhack your kernel (if you are into that sortof thing) by changingdrivers/char/tty_io.c to change the lines where it sets "noctty = 1;"to instead set it to "0". I recommend you instead run yourshell on a real console。
解决方法如下:
1.在dev目录下建立ttyS0的节点:
#mknod –m 666 ttyS0 c4 64
2. 然后我们将系统控制台console链接到ttyS0中
# ln –s ttyS0 console
3.修改启动文件/etc/inittab
console::sysinit:-/etc/rcS
ttyS0::respawn:-/bin/sh
这边我们要关注一下busybox的inittab文件的格式:
Id:runlevel: action :process
其中的Id是用来指定启动的控制台的。
到此为止,重新制作文件系统,下载到目标板,测试。