From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 12 May 2015 17:15:45 +0100 Message-ID: From: Charles Forsyth To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a1134c5948fa5350515e4ce60 Subject: Re: [9fans] on cp /fd/1 /fd/0 Topicbox-Message-UUID: 52935a9c-ead9-11e9-9d60-3106f5b1d025 --001a1134c5948fa5350515e4ce60 Content-Type: text/plain; charset=UTF-8 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'm not able to change permissions on /fd/1. Why not? > Because if those changed permissions worked, that would in principle allow you to force write access to a file you'd opened with read. The "inappropriate use" message is possibly a bad choice. It's normally returned for attempting to write to a file descriptor open for read (or conversely). The usual "permission denied" message would be better for open. --001a1134c5948fa5350515e4ce60 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On 12 May 2015 at 15:17, Daniel Bastos <dbastos@toledo.com>= wrote:
What is the relationship betwe= en 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= 9;ll both always present the same behavior?

open /fd/1 and you get a new file descriptor number that refers to t= he 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 =C2=A0= shows what you get.

I= 'm not able to change permissions on /fd/1. Why not?
=

Because if those changed permissions worked, that would= in principle allow you to force write access to =C2=A0a file you'd ope= ned with read.

The "inappropriate use" = message is possibly a bad choice. It's normally returned for attempting= to write
to a file descriptor open for rea= d (or conversely). The usual "permission denied" message would be= better for open.

--001a1134c5948fa5350515e4ce60--