title: File Descriptors, open() returns zero
body: <p>i open a file and want to write something in it. The problem is that the fd2 for some reason is 0. Instead of writting in the file, it writes on terminal. I dont  close(0) anywhere in my code. Why do i get fd = 0 and not for example 3. The reason that writes on terminal is that the value of fd is zero? I know that fd = 0 is for standard input,</p>
  
  <p>Any Ideas? Thank you. </p>
  
  <pre><code>if ((fd2 = open(logFile, O_RDWR |O_APPEND | O_CREAT , 0666) == -1))
      DieWithError("open() failed");
  
  printf("FD2 = %d",fd2);     //returns me zero
  
  bzero(tempStr, sizeof(tempStr));
  bzero(hostname, sizeof(hostname));
  
  gethostname(hostname, sizeof(hostname));
  
  sprintf(tempStr, "\n%sStarting FTP Server on host %s in port %d\n", ctime(&amp;currentime), hostname, port);
  
  if (write(fd2, tempStr, strlen(tempStr)) == -1)
      DieWithError("write(): failed");
  </code></pre>