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'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.

Reply via email to