六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 83|回复: 0

恢复在console模式下无法使用Ctrl-C

[复制链接]

升级  14.54%

1227

主题

1227

主题

1227

主题

榜眼

Rank: 8Rank: 8

积分
3727
 楼主| 发表于 2013-2-1 12:26:12 | 显示全部楼层 |阅读模式
What is the correct procedure to follow to get around this problem and get ctrl-c working on console?

It looks like everyone is taking a swing at this one, so I think I'll
join in. First off, the easiest way I've found to track down why
ctrl-c doesn't work is to just run "ps -j". For ctrl-c to work, you
need a controlling terminal (the TTY column) and a process group. If
you have a '?' in the TTY column, ctrl-c won't work. In the past I
have seen this happen because of this code in drivers/char/tty_io.c:
if (device == SYSCONS_DEV) {
struct console *c = console_drivers;
while(c && !c->device)
c = c->next;
if (!c)
return -ENODEV;
device = c->device(c);
filp->f_flags |= O_NONBLOCK; /* Don't let /dev/console block */
noctty = 1;
}
Note that O_NOCTTY (no controlling terminal) is forced on whenever
/dev/console is opened (noctty = 1). Possible workarounds:
1) Run getty on something other than /dev/console. For example,
if you console is on the first serial port, run getty on /dev/ttyS0.
I believe this is the "correct" answer.
2) You could also change getty to do a TIOCSCTTY ioctl explicitly after
it has opened the terminal.
3) You could remove the forcing of noctty on from tty_io.c

Scott Anderson
scott_anderson at mvista.com MontaVista Software Inc.
(408)328-9214 1237 East Arques Ave.
http://www.mvista.com Sunnyvale, CA 94085
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表