title: how to iterate over PCB's to show information in a Linux Kernel Module?
body: <p>I want to write a little Linux Kernel Module that can show me the PID of all running processes.
  I have the following code:</p>
  
  <pre><code>/*
   * procInfo.c  My Kernel Module for process info
   */
  
  #include &lt;linux/init.h&gt;
  #include &lt;linux/module.h&gt;
  #include &lt;linux/kernel.h&gt;
  
  /*
   * The init function, called when the module is loaded.
   * Returns zero if successfully loaded, nonzero otherwise.
   */
  static int mod_init(void)
  {
          printk(KERN_ALERT "ProcInfo sucessfully loaded.\n");
          return 0;
  }
  
  /*
   * The exit function, called when the module is removed.
   */
  static void mod_exit(void)
  {
          printk(KERN_ALERT "ProcInfo sucessfully unloaded.\n");
  }
  
  void getProcInfo()
  {
          printk(KERN_INFO "The process is \"%s\" (pid %i)\n",
          current-&gt;comm, current-&gt;pid);
  }
  
  module_init(mod_init);
  module_exit(mod_exit);
  MODULE_LICENSE("GPL");
  MODULE_AUTHOR("Rodrigo");
  </code></pre>
  
  <p>As you can see, i know i have to use the *struct task_struct* structure to get the PID and the Process name, but i am using <em>current</em>, and i know the existance of some double linked circular list that contains all PCB's, so the main question is:
  what do i need to add to iterate over this linked lisk with p-next_task and p-prev_task so getProcInfo works?
  Thanks!</p>