1

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.

Roger
  • 7,535
  • 5
  • 41
  • 63

3 Answers3

1

Try configuring the kernel through boot parameters with the option:

loglevel=3 (or a lower value)

        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

source: https://www.kernel.org/doc/Documentation/kernel-parameters.txt

See also: Change default console loglevel during boot up

Community
  • 1
  • 1
JohannesB
  • 2,214
  • 1
  • 11
  • 18
1

You should be able to use openvt to have your program run on a new Virtual Terminal.

I'll also note that it should be possible to embed control for the VTs yourself if you prefer to break the external dependency, but note that structures used may not be stable between kernel versions, and may require recompilation. See the KBD project's sources, specifically openvt.c to see how it works.

Hasturkun
  • 35,395
  • 6
  • 71
  • 104
0

It might be impossible to block some other process with sufficient access from writing to /dev/console but you may be able to redefine console as some other device, at boot time by setting console=ttyS0 (first serial port), see:

https://unix.stackexchange.com/questions/60641/linux-difference-between-dev-console-dev-tty-and-dev-tty0

Also if we know exactly which software is sending the message it may be possible to reconfigure it (possibly dynamically) but it would help to know the version and edition of Tiny Core Linux you are using?

E.g. this website has a "Core", "TinyCore" and "CorePlus" versions 1.x up to 7

http://tinycorelinux.net/downloads.html

This would help reproducing the exact same behavior and testing potential solutions.

Community
  • 1
  • 1
JohannesB
  • 2,214
  • 1
  • 11
  • 18