Artificial intelligent assistant

Is a file descriptor ever NOT open? Of course a file can be open, or not open. However, a file descriptor by definition refers to an open file (right?). (Well, except when it refers to something besides a file, like a pipe or what have you. But it's still open.) I've encountered the phrase "open file descriptor" several times. I _believe_ this is redundant, and that in fact there is no other kind of file descriptor besides an open file descriptor—but I would like to verify this. Is a file descriptor ever in any other state besides "open"? (When it's closed, doesn't it cease to exist?)

A program executes this:


close(0);

The standard input file descriptor has not changed value, but it is no longer referencing an open file description. It is available for re-allocation. Subsequent attempts to use it in, say, `read()` will result in `EBADF` because whilst _it is still a file descriptor_ it is not an allocated one that references an open file description. It is a _bad_ file descriptor.

# Further reading

* "`close()`". _The Open Group Base Specifications_ Issue 7. IEEE 1003.1:2008. The Open Group. 2018.
* "`read()`". _The Open Group Base Specifications_ Issue 7. IEEE 1003.1:2008. The Open Group. 2018.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 266834d06b4fe1899185182a6bcf66b1