亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1207 | 回復: 0
打印 上一主題 下一主題

busybox ctrl+c不能終止進程 [復制鏈接]

論壇徽章:
0
跳轉到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2009-10-08 17:17 |只看該作者 |倒序瀏覽

最近的一段時間中,發(fā)現在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中的驅動中的。在我原來的文件系統中,建立了節(jié)點console作為系統控制臺。但是沒有ttyS0節(jié)點。這樣系統運行起來后,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中。

所以我們解決方法如下:
1.
在dev目錄下建立ttyS0的節(jié)點:
#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: action :process
其中的Id是用來指定啟動的控制臺的。
到此為止,重新制作文件系統,下載到目標板,測試:
# ping 192.168.2.245
PING 192.168.2.245 (192.168.2.245): 56 data 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
#
測試通過!
網上還有介紹其他的方法如下:
修改內核源碼
在內核源碼drivers/char/tty_io.c中將
noctty = 1改為noctty = 0
然后/etc/inittab可以使用默認的,也可以寫成:
console::sysinit:-/etc/rcS
console::respawn:-/bin/sh


本文來自ChinaUnix博客,如果查看原文請點:http://blog.chinaunix.net/u1/37080/showart_2065792.html
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯網協會會員  聯系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉載本站內容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP