title: fopen in C(Linux) returns "Too many open files"
body: <pre><code>static char filename[128] = "trace.txt";
  
  g_file = fopen(filename, "w");
  if(NULL == g_file)
  {
         printf("Cannot open file %s.error %s\n",filename,strerror(errno));
         exit(1);
  }
  </code></pre>
  
  <p>I am trying to open a empty text file named trace.txt in write mode (in my working directory.)
  The program is creating an empty file trace.txt in my directory.but the check (NULL == g_file)
  is returning true and it is returning error code 24 (Too many open files.).Any idea why this is.This is the first file I am opening in my program.</p>
  
  <p>Surprisingly the code is creating an empty file in my working directory by the name specified.However the check for null file pointer is succeeding for some reason.? :(</p>