How to print a message in one single line in Linux kernel

后端 未结 2 1741
借酒劲吻你
借酒劲吻你 2021-01-04 14:13

I am making a simple enque/deque program in kernel. I want to print message in kernel, and this is what I got:

[18594.595747] Enqueue 3 
[18594.595748]  queu         


        
相关标签:
2条回答
  • 2021-01-04 14:36

    Debugging by printing

    printk(KERN_ERR "Doing something was ");
    /* <100 lines of whatever>*/
    if (success)
       printk(KERN_CONT "successful\n");
    else
       printk(KERN_CONT "NOT successful\n");
    

    Logging prints should be safe: SFP vs single CPU.

    0 讨论(0)
  • 2021-01-04 14:56

    To prevent a new line from being started, use KERN_CONT:

    printk(KERN_ALERT "self destruction commences in ");
    printk(KERN_CONT "%d", time_remaining);
    printk(KERN_CONT " minutes\n");
    
    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题