Im looking for a way how to get rid of (kernel?) messages that appear in my ncurses app. I wrote the app myself, so i would prefer a API that redirects these messages to /dev/null. I mean messages like, a USB stick that is inserted.
I tried to add this, but unfortunately it doesn't work
freopen("/dev/null", "w", stderr);
I'm not running X, just ncurses direct from the console.
I mean messages like, a USB stick that is inserted.
Thanks!
UPDATE 1: Someone votes to close this question because it would not be related to programming. But it is, i wrote the ncurses app myself, i'm looking for a way how to disable the kernel message. I updated the question.
UPDATE 2: Let me explain what i'm doing, and whats the problem in more detail:
I'm using Tiny Core linux, thats after boots starts (self written) ncurses program. Now when you for example connect a USB drive, a message (i suspect kernel) is shown over my program. I guess the message is written straight into the framebuffer. Im using TC 5.x since i need 32 bit, im running as root and have full access to the os.
答案 0 :(得分:1)
您应该可以使用openvt
让您的程序在新的虚拟终端上运行。
我还要注意,如果您希望打破外部依赖关系,应该可以自己嵌入VT控件,但请注意,在内核版本之间使用的结构可能不稳定,并且可能需要重新编译。 请参阅KBD project's来源,特别是openvt.c,了解其工作原理。
答案 1 :(得分:0)
尝试使用以下选项通过引导参数配置内核:
loglevel = 3(或更低的值)
0 (KERN_EMERG) system is unusable
1 (KERN_ALERT) action must be taken immediately
2 (KERN_CRIT) critical conditions
3 (KERN_ERR) error conditions
4 (KERN_WARNING) warning conditions
5 (KERN_NOTICE) normal but significant condition
6 (KERN_INFO) informational
7 (KERN_DEBUG) debug-level messages
来源:https://www.kernel.org/doc/Documentation/kernel-parameters.txt
答案 2 :(得分:0)
通过写入/ dev / console可能无法阻止某些其他进程具有足够的访问权限,但您可以通过设置console = ttyS0(第一个串口)在启动时将控制台重新定义为其他设备,请参阅:
此外,如果我们确切地知道哪个软件正在发送消息,则可以重新配置它(可能是动态的),但是有助于了解您正在使用的Tiny Core Linux的版本和版本?
E.g。这个网站有一个" Core"," TinyCore"和#34; CorePlus"版本1.x至7
http://tinycorelinux.net/downloads.html
这有助于重现完全相同的行为并测试潜在的解决方案。