title: Passing Linux boot opts to Init
body: <p>I would like to pass some parameters to a customized Linux init via the boot options configured in the bootloader at boot.</p>
  
  <p>I've written test init's in both Python and C.  The Python version is able to see anything in the kernel boot options that doesn't have a '=' or '.' in it.  The values are found in sys.argv.  However, the C program doesn't seem to get passed the values.  I would have thought the sys.argv list in Python was generated by parsing the **argv array.  Below are the test scripts and screen shots that will hopefully help clarify.</p>
  
  <p>the kernel boot line is: </p>
  
  <p><code>kernel /grub/linux-2.6.38.4 root=/dev/vda1 init=/argv-{p|c} one two three four five</code></p>
  
  <p>Python version:</p>
  
  <pre><code>#!/usr/bin/python
  
  import sys
  
  i = 0
  print("Printing argv[] (Python) ...")
  for each in range(i, len(sys.argv)):
      print("argv[%d] - %s" % (i, sys.argv[i]))
      i += 1
  print("...finished printing argv[]")
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/DGXbB.png" alt="Python init argv test"></p>
  
  <p>C version:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char **argv)
  {
      int i;
      printf("Printing argv[] (C) ...\n");
      for(i; i &lt; argc; i++) {
          printf("argv[%d] - %s\n", i, argv[i]);
      }
      printf("...finished printing argv[]\n");
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/bWwKS.png" alt="C init argv test"></p>
  
  <p>You can see just before the test programs exit (and causes panic) the python version spits out the boot options the kernel didn't digest while the C version didn't. I've looked at the sysvinit source code and it looks to me (not being a C dev) that it works the same way?</p>
  
  <p>How do I get the boot options passed to my C init program?</p>
  
  <p>(oh, and the C program works as expected when not being run as init)</p>