“冻结”终端输出(/dev/tty1)
我正在编写一个直接在帧缓冲区(/dev/fb0)上操作的应用程序(用java)。
当我启动我的应用程序时,当前活动控制台的光标仍然闪烁,如果我使用向上/向下等键盘键,控制台将显示最近使用的命令并覆盖帧缓冲区的内容。
我只能阻止光标闪烁:
setterm -cursor off > /dev/tty1
有没有办法完全冻结(然后解冻)控制台?
X-Server 似乎也做同样的事情。如果引导进程在 GraphicsCard-1 上运行,而 X 服务器在 GraphicsCard-2 上运行,则当 X 启动时,GraphicsCard-1 上的输出将立即停止(不闪烁光标)。我想如果将视频输出设置到帧缓冲区,mplayer 也会这样做。
感谢您的任何想法:)
I'm writing an application (in java) that directly operates on the framebuffer (/dev/fb0).
When I start my app, the cursor of the currently active console still blinks and if i use keyboard-keys like up/down the console will display the recently used commands and overwrite the framebuffer's content.
I was only able to stop the cursor from blinking:
setterm -cursor off > /dev/tty1
Is there a way to totally freeze (and later unfreeze) the console?
It seems like an X-Server does the same thing. If the boot-process runs on GraphicsCard-1 and the X-Server on GraphicsCard-2, the output on GraphicsCard-1 will stop (no blinking cursor) immediately when X starts. I guess mplayer does this, too if setting video-out to the framebuffer.
thanks for any ideas :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
严格来说,您观察到的行为更多的是错误而不是功能。这是因为 Linux 并不是真正的多头系统。您所看到的是 X 服务器切换其自己的分配的效果 虚拟终端到控制台。当然,这是因为一次只能一个虚拟终端在系统范围内处于活动状态--切换正在显示的虚拟终端,即使它显示在完全是另一个显示适配器。
您必须执行 X 服务器正在执行的一些操作,并且将您自己的虚拟终端切换到控制台。
Strictly speaking, the behaviour that you've observed is more of a bug than a feature. It's down to the fact that Linux isn't properly multi-head. What you're seeing is an effect of the X server switching its own, allocated, virtual terminal onto the console. This of course — because only one virtual terminal can be active at a time system-wide — switches out the virtual terminal that was being displayed, even though it was being displayed on another display adapter entirely.
You have to do some of what the X server is doing, and switch your own virtual terminal onto the console.
openvt(1)
允许您在新的虚拟终端中打开程序,chvt(1)
允许您切换到另一个虚拟终端。openvt(1)
allows you to open a program in a new virtual terminal, andchvt(1)
allows you to switch to another virtual terminal.要获得我真正想要的东西有点棘手:
我必须(从 shell)执行 2 个命令才能使终端安静:
稍后可以切换回终端 1:
我选择终端号 9,但任何高于 7 的数字都应该没事。如果这些调用是从 java 应用程序内部执行的,它们也可以工作(正如 JdeBP 所说,系统范围内只有一个虚拟终端)。只有 setterm 命令需要一些额外的步骤来将输出传输到 /dev/tty9:
也许 pipeline() 方法不是最佳的,但它对我来说是这样的。
it was a little bit more tricky to get what i exactly wanted:
I have to execute (from shell) 2 commands to get the terminal quiet:
later one can switch back to terminal 1:
I choose terminal number 9 but any number above 7 should be fine. These calls also work if they are executed from within the java application (as JdeBP said, only one virtual terminal system-wide). Only the setterm command requires some additional steps to pipe the output to /dev/tty9:
maybe the pipe() method is not optimal, but it worked for me the way it is.