From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: From: Daniel Bastos Date: Tue, 12 May 2015 14:10:45 -0300 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Subject: Re: [9fans] on cp /fd/1 /fd/0 Topicbox-Message-UUID: 5297f5c0-ead9-11e9-9d60-3106f5b1d025 On Tue, May 12, 2015 at 1:15 PM, Charles Forsyth wrote: > On 12 May 2015 at 15:17, Daniel Bastos 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?