9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "rob pike" <rob@plan9.bell-labs.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] pipefile
Date: Sun, 30 Jul 2000 21:14:55 -0400	[thread overview]
Message-ID: <200007310115.VAA03125@cse.psu.edu> (raw)

> If you don't mind, could you also say a word as to what made the
> /dev/cons case special?  Who was writing to /dev/cons all of the 
> keyboard input so that it worked? (rio?)

/dev/cons is connected to standard in and standard out, that's all.
I stupidly had file descriptors 0 and 1 wired into the code.
Nobody was writing any keyboard input of any kind to /dev/cons.

What pipefile does is place filters between the file and
any subsequent program that opens it for i/o, by binding a pipe
onto the file and then connecting the filters to the pipe.  The other
end of the pipe is connected to the underlying file.

Normally you have, in effect,

	</dev/cons  rc   >/dev/cons

but after

	pipefile -r 'readcmd' -w 'writecmd' /dev/cons
	rc < /dev/cons >/dev/cons

you have, almost literally,

	</dev/cons readcmd | rc | writecmd >/dev/cons

(The only difference is that it uses one full duplex pipe instead
of two half duplex ones.)

What was special about /dev/cons was that I had this
example in mind when I wrote the program, so what
it actually did was closer to

	</fd/0 readcmd | rc | writecmd >/fd/1

The fix was to open the file explicitly.

Hope that helps.

-rob



             reply	other threads:[~2000-07-31  1:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-31  1:14 rob pike [this message]
2000-08-02  3:40 ` Skip Tavakkolian
2000-08-03  1:21   ` Skip Tavakkolian
  -- strict thread matches above, loose matches on Subject: below --
2000-08-03 23:46 okamoto
2000-08-03  4:49 rob pike
2000-08-03  4:15 okamoto
2000-08-03  3:44 okamoto
2000-08-03  7:14 ` Matt
2000-08-03  3:19 okamoto
2000-08-03  0:19 okamoto
2000-08-02 21:19 rob pike
     [not found] <rob@plan9.bell-labs.com>
2000-08-02 14:48 ` rob pike
2000-08-02 15:49   ` James A. Robinson
2000-08-02  7:55 okamoto
2000-08-03  8:21 ` Boyd Roberts
2000-07-31  9:47 okamoto
2000-07-31  4:55 rob pike
2000-07-31  4:40 okamoto
2000-07-30 23:46 Steve Harris
2000-07-30 23:17 rob pike
2000-07-30 23:06 rob pike
2000-07-30 22:38 Steve Harris
2000-07-30 19:54 rob pike

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=200007310115.VAA03125@cse.psu.edu \
    --to=rob@plan9.bell-labs.com \
    --cc=9fans@cse.psu.edu \
    /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).