ctrl+c不能终止进程

1.如果是; 映射键,可以在右键鼠标看下;会话选项 ->,是不是复制的快捷键是ctrl+c; 仿真 ->,在菜单栏找到 选项 ->终端 ->,

有个CUA设置应该是Ctrl+C组合键被设置成了复制


2.ctrl+c不能终止进程(busybox提示can't access tty.job control在最近的一段时间中,发现在busybox下调试时,shell终端用ctrl+c不能终止掉正在运行的进程。参考了网上的一些网友的blog的解决方法以及自己的理解,这边把解决方法告诉大家。
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) 来中断每个具有group number 为 tty->pgrp的task.值得一提的是,只要process具有相同的group id,不管是backgroud还是foreground,都会被kill掉
从上面的流程我们可以看到,ctrl+C是传送到/dev/ttyS0中的驱动中的。在我原来的文件系统中,建立了节点console作为系统控制台。但是没有ttyS0节点。这样系统运行起来后,shell的交互是通过console这个控制台的。但是在busybox的手册中有这样的一段话:
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...
显然,busybox建议我们shell最好运行在实际的控制台上,例如tty或是ttyS0中。
2011年10月26日 - 喧闹的寂寞 - 喧闹的寂寞
所以我们解决方法如下:
1.    在dev目录下建立ttyS0的节点:
#mknod –m 666 ttyS0 c 4 64
2.    然后我们将系统控制台console链接到ttyS0中
# ln –s ttyS0 console
3.    修改启动文件/etc/inittab
       console::sysinit:-/etc/rcS
ttyS0::respawn:-/bin/sh
这边我们要关注一下busybox的inittab文件的格式:
Id:runlevel: act

ion :process
其中的Id是用来指定启动的控制台的。
到此为止,重新制作文件系统,下载到目标板,测试:
# ping 192.168.2.245
PING 192.168.2.245 (192.168.2.245): 56 da ta bytes
64 bytes from 192.168.2.245: icmp_seq=0 ttl=64 time=2.1 ms
64 bytes from 192.168.2.245: icmp_seq=1 ttl=64 time=0.6 ms
64 bytes from 192.168.2.245: icmp_seq=2 ttl=64 time=0.4 ms
64 bytes from 192.168.2.245: icmp_seq=3 ttl=64 time=0.4 ms
--- 192.168.2.245 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 0.4/0.8/2.1 ms
#

3.网上还有介绍其他的方法如下:
修改内核源码
在内核源码drivers/char/tty_io.c中将
noctty = 1改为noctty = 0
然后/etc/inittab可以使用默认的,也可以写成:
console::sysinit:-/etc/rcS
console::respawn:-/bin/sh

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值