title: System Call in a System Call
body: <p>Hi I'm trying to add a custom system call to a lubuntu kernel.I'm trying to kill a process within this system call. I tried kill() system call in original ubuntu kernel. But i got compiler errors while doing that. I have no idea how to do that properly. Thanks in advance for your answers.</p>
  
  <pre><code>#define _POSIX_SOURCE
  #include &lt;linux/syscalls.h&gt;
  #include &lt;linux/kernel.h&gt;
  #include &lt;linux/sched.h&gt;
  #include &lt;linux/list.h&gt;
  #include &lt;linux/signal.h&gt;
  #include &lt;linux/types.h&gt;
  
  asmlinkage long sys_my_process_terminator (pid_t pid , int flag) 
  {
  
         struct task_struct *task;
         struct list_head *list;
      struct list_head *siblist;
  
      // firstly check the flag 
      struct task_struct *myprocess;
          struct task_struct *sibchild;
      myprocess = find_task_by_vpid(pid);
      struct task_struct *pp;
      pp =myprocess-&gt;parent;
      if (flag == 0){
  
      // this loop under this comment will kill all the children of the given process
  
      list_for_each(list, &amp;myprocess-&gt;children) {
          task = list_entry(list, struct task_struct, sibling);
      printk ("%s [%d] \n" , task-&gt;comm , task-&gt;pid);
      kill(task-&gt;pid,SIGKILL);
      }
  
      }
  
      else if (flag==1) {
  
      list_for_each(list, &amp;pp-&gt;children) {
          task = list_entry(list, struct task_struct, sibling);
  
      list_for_each(siblist, &amp;task-&gt;children) {
          sibchild = list_entry(siblist, struct task_struct, sibling);
      printk ("%s [%d] \n" , sibchild-&gt;comm , sibchild-&gt;pid);
      kill(sibchild-&gt;pid,SIGKILL);
      }
      if (task-&gt;pid !=pid){
      printk ("%s [%d] \n" , task-&gt;comm , task-&gt;pid);
      kill(task-&gt;pid,
  
  }
  </code></pre>