[beagleboard] ERRNO 9 / Bad File Number after Hours accessing


The EBADF may not be your actual problem, because immediately before exiting the loop you attempt to close an invalid file descriptor: In the “then” part of your if statement, you verify in the condition that the output_fd is less than zero (an invalid file descriptor), then you call close() on that invalid file descriptor (which also returns an error, but you don’t see it because you’re not checking the return value of close() there). Once you break out of the loop, errno is set to EBADF from the close() call, not from the open() call.

You should add the printout as the first line inside of the “then” block of your if ( output_fd < 0 ) – that will tell you what errno was returned from the open() call.