2

I wrote a system call that outputs system information to the kernel log. Here is an example program that invokes my system call.

#include <stdio.h>
#include <linux/unistd.h>
int main()
{
    int ret = syscall(351, 2);
    printf(“%d\n”, ret);
    if(ret == 2)
        printf(“the first syscall is success!\n);
    return 0;
}

Now, I want to see the output differently. Instead of using dmesg to read the kernel log, I want the system call to output the result directly to the terminal (of the calling process in the simplest case, or even just to its standard output).

How can I arrange to do that?

  • Which terminal? Put another way, how would the system call know where to send its output? – Stephen Kitt Oct 24 '18 at 13:43
  • 1
    Don't skimp on bytes; feel free to put your actual question in the Question... – Jeff Schaller Oct 24 '18 at 13:46
  • I wrote a system call that outputs system informations. I want to see the output now, but instead of using dmesg, I want to output the result directly to the terminal. – wyc Oct 24 '18 at 13:52
  • If your syscall uses printk switch to tty and do dmesg -n8, it modifies some files in /proc under the hood - you will now see the output. – Arkadiusz Drabczyk Oct 24 '18 at 14:01
  • ... or alternatively use something like console=ttyS0,115200 if your hardware has UART – Arkadiusz Drabczyk Oct 24 '18 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.