Either a file descriptor refers to no open file, or a read(2)--or a write(2)--request is made to a file that is open only for writing or reading.
The symbolic name for this error is EBADF, errno=9.