title: Why does open() fail and errno is not set?
body: <p>In my code <code>open()</code> fails with a return code of -1 but somehow <code>errno</code> is not getting set.</p>
  
  <pre><code>int fd;
  int errno=0;
  fd = open("/dev/tty0", O_RDWR | O_SYNC);
  printf("errno is %d and fd is %d",errno,fd);
  </code></pre>
  
  <p>output is</p>
  
  <pre><code>errno is 0 and fd is -1
  </code></pre>
  
  <p>Why is errno not being set?  How can i determine why <code>open()</code> fails?</p>