title: File locks for linux
body: <p>I tried using temp files:</p>
  
  <pre><code>char *temp = tempnam(NULL, "myapp_");
  printf("Tempname: %s", temp)     // Prints /tmp/myapp_random
  while (1) { }
  </code></pre>
  
  <p>But when I check <code>/tmp</code> (while the app is still running), the myapp_random is not there!</p>
  
  <p>As for using File Locks, I can't get a good grasp on it, I tried looking at <code>&lt;fcntl.h&gt;</code> but it seems to focus on locks in specified portions of a file. I just want to use the file entirely as a lock (which is why I prefer trying the temp file approach).</p>
  
  <p>Any ideas?</p>