title: Restricting program to run only one instance
body: <p>Here's a simple "hello world" C program that takes 10 seconds to complete:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  main()
  {
      printf("hello World 1 \n");
      fflush(stdout);
      sleep(10);
      printf("hello World 2 \n");
      fflush(stdout);
  }
  </code></pre>
  
  <p>How can I modify it so at most only one instance of this executable can run at any moment in time? I'm using Linux.</p>
  
  <p>For example, assume the server crashes if more than one instance is run simultaneously, and we're trying to prevent this. I'd like to see one or more example(s) of different ways so I can run and verify on my system. </p>
  
  <p>Also, is there a simple way to queue them so if I run the C executable twice in a row, the second one runs just after the first one completes?</p>