On Tue, May 12, 2015 at 1:15 PM, Charles Forsyth <[email protected]> wrote: > On 12 May 2015 at 15:17, Daniel Bastos <[email protected]> wrote: >> >> What is the relationship between file descriptor 1 and /fd/1? When a >> program runs, 1 is already open for writing. But apparently it's open only >> for writing. A read on it yields inappropriate use of fd. The same seems to >> happen /fd/1. Can I say they'll both always present the same behavior? > > open /fd/1 and you get a new file descriptor number that refers to the same > open file as file descriptor 1, and with the same open mode > (the new open can add OCEXEC, which will apply to both). /fd/1ctl shows > what you get.
I don't follow you. The only way I could open successfully was to specify OWRITE (with or without OCEXEC). The results were expected: with OCEXEC, the fd was closed after an exec, without it it was kept open. I don't know what you wanted to show me. My conclusion is that cp /fd/1 anything could never work because it requires opening /fd/1 for reading, which is not possible. Is this conclusion incorrect?
