title: Can multiple processes append to a file using fopen without any concurrency problems?
body: <p>I have a process opening a file in append mode.  In this case it is a log file.  Sample code:</p>
  
  <pre><code>int main(int argc, char **argv) {
      FILE *f;
      f = fopen("log.txt", "a");
      fprintf(f, "log entry line");
      fclose(f);
  }
  </code></pre>
  
  <p>Two questions:</p>
  
  <ol>
  <li>If I have multiple processes appending to the same file, will each log line appear distinctly or can they be interlaced as the processes context switch?</li>
  <li>Will this write block if lots of processes require access to the file, therefore causing concurrency problems?</li>
  </ol>
  
  <p>I am considering either doing this in its simplest incarnation or using zeromq to pump log entries over pipes to a log collector.  </p>
  
  <p>I did consider syslog but I don't really want any platform dependencies on the software.</p>
  
  <p>The default platform is Linux for this btw.</p>