9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Daniel Bastos <dbastos@toledo.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] on cp /fd/1 /fd/0
Date: Tue, 12 May 2015 14:10:45 -0300	[thread overview]
Message-ID: <CAB08-qqnU-mNTTZHekirNFGQ--NrELg=xsMen+tedT47TaMYWw@mail.gmail.com> (raw)
In-Reply-To: <CAOw7k5i9RHTCS_teRt4_soz-ujQjxm-9j=mZTg89dcGj5rYmng@mail.gmail.com>

On Tue, May 12, 2015 at 1:15 PM, Charles Forsyth
<charles.forsyth@gmail.com> wrote:
> On 12 May 2015 at 15:17, Daniel Bastos <dbastos@toledo.com> 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?



  reply	other threads:[~2015-05-12 17:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12 11:56 Daniel Bastos
2015-05-12 12:24 ` Iruatã Souza
2015-05-12 12:39   ` lucio
2015-05-12 13:20     ` erik quanstrom
2015-05-12 14:17   ` Daniel Bastos
2015-05-12 16:15     ` Charles Forsyth
2015-05-12 17:10       ` Daniel Bastos [this message]
2015-05-12 18:54         ` Charles Forsyth
2015-05-12 15:52 ` Charles Forsyth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAB08-qqnU-mNTTZHekirNFGQ--NrELg=xsMen+tedT47TaMYWw@mail.gmail.com' \
    --to=dbastos@toledo.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).