2 Replies Latest reply on Nov 27, 2009 9:34 PM by 800381

    fgets from stdin - Bad file number


      Here is a sample code that is giving problems:
      while (true) {
         readBufPtr = fgets (buf, sizeof(buf), stdin);
         if (readBufPtr)
           syslog (LOG_INFO, buf);
         else if (EINTR != errno) {
           syslog (LOG_ERR, "[ESReadStdin] read from stdin failed. Reason: [%s]. Exiting.\n", strerror (errno));
      The fgets call gives the EBADF error and the program terminates saying :
      [ID 381367 local5.error] [ESReadStdin] read from stdin failed. Reason: [Bad file number]. Exiting

      Why would reading from stdin give an EBADF ? Is there any something I can check on the system. Note that this happening only on one machine.