Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • This is good information, thank you. I did the following test: I closed stdin with "exec 0<&-" (by the way, running simply "0<&-" immediately closed me out of my bash shell). I then ran the above compiled C code, but it consistently returned "3" instead of the now presumably available 0 as a filehandle. Is my test incorrect? Commented Nov 12, 2013 at 21:00
  • Each process has its own i/o descriptors. Close the shell's input, it quits. To run the above program with a closed input, run it with e.g. ./fd0 <&-. Commented Nov 12, 2013 at 21:12