49 ms·
> stdin, stdout, and stderr are files 0, 1, and 2. Always. Shouldn't this be something closer to "stdin, stdout, and stderr are always initially fds 0, 1, and
by JadeNB 12y ago
> stdin, stdout, and stderr are files 0, 1, and 2. Always.
Shouldn't this be something closer to "stdin, stdout, and stderr are always initially fds 0, 1, and 2"? I thought that one could play some trickery to change this. (I'm not being intentionally snarky, and might be quite wrong.)
- falcolas 12y agoThey can, yes. If you close all of them, the next files you open will get the 0, 1, and 2 file descriptors. It's a fairly common idiom to close everything, open a handle to /dev/null, and duplicate it twice to get 0, 1, and 2 pointing at /dev/null.