title: How do I get the output of a Linux System Call in C/C++?
body: <p>I've added a simple <code>helloworld</code> system call to my Linux Kernel.</p>
  
  <p><strong>sys_helloworld</strong></p>
  
  <pre><code>#include &lt;linux/kernel.h&gt;
  
  asmlinkage long sys_helloworld(void)
  {
          printk("Hello world\n");
          return 0;
  }
  </code></pre>
  
  <p>It just print out <code>Hello world</code> to the kernel log.</p>
  
  <p>I called <code>sys_helloworld</code> system call like so :</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;linux/kernel.h&gt;
  #include &lt;sys/syscall.h&gt;
  #include &lt;unistd.h&gt;
  int main()
  {
     long int a = syscall(314); // 314 is the line number of sys_helloworld in syscall table
     printf("System call sys_helloworld returned %ld\n", a);
     return 0;
  }
  </code></pre>
  
  <p>Above program successfully prints <code>Hello world</code> in kernel log.</p>
  
  <p><strong>My Question :</strong></p>
  
  <p>How do I get the output of <code>sys_hello</code> (which prints <code>Hello world</code> to the kernel log) in my program?</p>