problems with /dev/console and "job control"

问题描述:exec </dev/tty1 >/dev/tty1 2>&1

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.

>

> Example: you booted into your machine with init=/bin/sh and got "sh: can‘t

> access tty" error because sh has its stdio opened to /dev/console. You want

> to reopen stdio to, say, /dev/tty1 and thus acquire a controlling tty.

>

>     # Let‘s try this:

>     exec </dev/tty1 >/dev/tty1 2>&1

>     # No, doesn‘t work: even if opening /dev/tty1 gave sh the ctty,

>     # sh wouldn‘t know it - it checks for ctty just once at startup.

>

>     # Let‘s try re-execing sh:

>     exec </dev/tty1 >/dev/tty1 2>&1

>     exec sh

>     # Got "sh: can‘t access tty" again. Why?

>     # The reason is somewhat obscure: kernel starts process with PID=1

>     # (in this case, shell) with SID=0 and PGID=0, not with SID=1 and PGID=1

>     # as you‘d expect. IOW: our sh is not a session leader, and therefore

>     # cannot acquire ctty by opening /dev/tty1 (or any other tty).

>

>     # Let‘s try making us a session leader:

>     exec setsid sh

>     exec </dev/tty1 >/dev/tty1 2>&1

>     exec sh

>     # Yes, this worked!

>

>     # This can be combined into one command,

>     # but need to be careful and perform these operations

>     # in the correct order:

>     # 1. make ourself session leader,

>     # 2. open /dev/tty1 and thus acquire a ctty,

>     # 3. re-execute the shell, allowing it to notice that it has ctty:

>     exec setsid sh -c ‘exec sh </dev/tty1 >/dev/tty1 2>&1‘

>

> 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.

时间: 2024-10-10 22:13:49

problems with /dev/console and "job control"的相关文章

tiny210 NFS挂载时出现/init: line 109: can&#39;t open /r/dev/console: Permission denied,解决办法

在主机文件系统下,修改/dev/console 的权限,sudo chmod 777 /dev/console,执行#ls -l后打印: crwxrwxrwx 1 root root 5, 1 2015-04-19 10:43 console tiny210 NFS挂载时出现/init: line 109: can't open /r/dev/console: Permission denied,解决办法

linux - console/terminal/virtual console/pseudo terminal ...

http://en.wikipedia.org/wiki/System_console System console Knoppix system console showing the boot process The system console, computer console, root console, operator's console, or simply console is the text entry and display device for system admin

Linux /proc、/dev Principle Learning

目录 1. /proc简介 2. 内核机制相关 3. 进程信息 4. 硬件设备相关 5. 系统信息 6. /dev简介 1. /proc简介 在linux的根目录下有一个/proc目录,/proc文件系统是一个虚拟文件系统,通过它可以使用一种新的方法在Linux内核空间和用户空间之间进行通信.在/proc文件系统中,我们可以将对虚拟文件的读写作为与内核中实体进行通信的一种手段,但是与普通文件不同的是,这些虚拟文件的内容都是动态创建的(即在我们执行指令的那一刹那才产生的) /proc文件系统包含了

【转】linux下tty,控制台,虚拟终端,串口,console(控制台终端)详解----不错

原文网址:http://blog.csdn.net/liaoxinmeng/article/details/5004743 首先: 1.终端和控制台都不是个人电脑的概念,而是多人共用的小型中型大型计算机上的概念.一台主机,连很多终端,终端为主机提供了人机接口,每个人都通过终端使用主机的资源. 终端有字符哑终端和图形终端两种.控制台是另一种人机接口, 不通过终端与主机相连, 而是通过显示卡-显示器和键盘接口分别与主机相连, 这是人控制主机的第一人机接口.话回到个人计算机上,个人计算机只有控制台,没

linux kernel下输入输出console怎样实现

近期工作在调试usb虚拟串口,让其作为kernel启动的调试串口,以及user空间的输入输出控制台. 利用这个机会,学习下printk怎样选择往哪个console输出以及user空间下控制台怎样选择.记录与此.与大家共享,也方便自己以后翻阅. Kernel版本号号:3.4.55 按照我的思路(还是时间顺序)分了4部分,指定kernel调试console ,  kernel下printk console的选择 ,kernel下console的注冊.user空间console的选择. 一 指定ker

devtmpfs和之前的dev

if [ ! -c /dev/ptmx ]; then # try to mount devtmpfs if ! mount -t devtmpfs -omode=0755 devtmpfs /dev >/dev/null 2>&1; then # if it failed fall back to normal tmpfs mount -t tmpfs -omode=0755 tmpfs /dev >/dev/null 2>&1 # Make some basic

如何解决 FrameBuffer console (vc)自动关闭显示

转载:http://blog.chinaunix.net/uid-9688646-id-1998294.html 控制台VT篇: 控制台VT有一个定时器,默认为10分钟,只要时间一到就会blank screen,会导致fb黑屏,会导致给人“电源管理的假象” 函数再现: static void blank_screen_t(unsigned long dummy) { if (unlikely(!keventd_up())) { mod_timer(&console_timer, jiffies

/dev/tty /dev/ttyS0 /dev/tty0区别 (转载)

1.串行端口终端(/dev/ttySn)  串行端口终端(Serial Port Terminal)是使用计算机串行端口连接的终端设备. 计算机把每个串行端口都看作是一个字符设备.有段时间这些串行端口设备通常被称为终端设备,因为那时它的最大用途就是用来连接终端.这些串行端口所对应的设备名称是/dev/tts/0(或/dev/ttyS0), /dev/tts/1(或/dev/ttyS1)等,设备号分别是(4,0), (4,1)等,分别对应于DOS系统下的COM1.COM2等. 若要向一个端口发送数

Kvm虚拟化(4)__为客户机添加virsh console支持

如果KVM下的linux是通过过vnc graphics方式安装的话,如果想在终端下通过virsh console进行管理连接时,发现敲任何键都没有反应,即不支持.而能不能通过修改配置文件达到像console安装或KS安装的效果 ? 答案是肯定的.具体操作步骤为编辑/etc/grub.conf文件在kernel内核行添加console=ttyS0然后重启机器即可. 这里面要注意的是:1.ttyS后面提零,不是大写的欧 .2.该修改在centos环境下测试通过.如果在其他系统下,如果修改此处不生效