The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Grant Taylor via TUHS <tuhs@minnie.tuhs.org>
To: tuhs@minnie.tuhs.org
Subject: Re: [TUHS] First appearance of named pipes
Date: Tue, 10 Mar 2020 20:47:39 -0600	[thread overview]
Message-ID: <4fb5b7ab-03a4-df64-d25b-8be587b6a17b@spamtrap.tnetconsulting.net> (raw)
In-Reply-To: <202003100729.02A7Tsg0002007@freefriends.org>

[-- Attachment #1: Type: text/plain, Size: 2361 bytes --]

On 3/10/20 1:29 AM, arnold@skeeve.com wrote:
> Absolutely:
> 
> 	$ mkfifo the_fifo
> 	$ ls -l  the_fifo
> 	prw-rw-r-- 1 arnold arnold 0 Mar 10 09:28 the_fifo
> 	$ echo foo > the_fifo & sleep 1 ; cat the_fifo
> 	[1] 3721
> 	foo
> 	[1]+  Done                    echo foo > the_fifo
> 
> As you stated, not that you'd want to do that, but you can.

Thank you for your reply Arnold.

As I was reading your reply, I realized that I did not fully convey the 
question that I was still mulling over in my head.  (More in a moment.)

This thread is one of about three things happening in my life that have 
to do with pipes, FIFOs, and file descriptors.  I managed to articulate 
the simpler of the questions while reading Noel's email.

The larger more onerous question is could I leverage exec to alter where 
file descriptors 0 (STDIN), 1 (STDOUT), and 2 (STDERR) are set to, 
including changing 1 to the value of a FIFO, and 0 of a subsequent 
command to also be the value of the FIFO, thus have pipe like behavior 
between two commands without using a pipe or redirection as in ">".

This has also gotten me to wonder about the possibility of having 
multiple commands output to a file descriptor; 1 / 2 / other, that is 
input to a separate command.  Sort of the opposite of tee, in a manner 
of speaking.  I'll try to articulate:

$ mkfifo test.fifo
$ exec 3>&1
$ exec 1> test.fifo
$ for l in {a..z}; do echo $l; sleep 1; done &
$ for L in {A..Z}; do echo $L; sleep 1; done &
$ for n in {1..100}; do echo $n; sleep 1; done &
$ exec 1>&3
$ cat test.fifo

This seems special to me in that I have three processes (for loops) 
writing into what is effectively the same pipe.

After having mulled this over for a few days and typing this out, I 
realize that the "pipe" is really just a fifo and that in this case the 
fifo is a named pipe on the file system.  I could do the same thing with 
a file.  Historically I would have done the same thing with a file.  But 
now I realize that the file is not required and that I can use a fifo 
which is in memory and never hits the disk.  (Save for creating the name 
interface to the pipe / fifo.)

At least, I think that's all accurate.

I would be very eager to learn from anyone who is willing to teach me 
pointers.  :-)



-- 
Grant. . . .
unix || die


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4013 bytes --]

  reply	other threads:[~2020-03-11  2:48 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-06 22:44 Noel Chiappa
2020-03-07 12:17 ` Paul Ruizendaal
2020-03-07 13:29   ` Clem Cole
2020-03-07 16:39   ` Derek Fawcus
2020-03-08  2:36     ` Rob Pike
2020-03-08  2:47       ` Larry McVoy
2020-03-08 13:07         ` Ralph Corderoy
2020-03-08 13:25           ` arnold
2020-03-08  3:06       ` Dave Horsfall
2020-03-08  7:16       ` arnold
2020-03-08 15:13       ` [TUHS] sockets (was Re: First appearance of named pipes) Derek Fawcus
2020-03-09 23:22         ` Grant Taylor via TUHS
2020-03-09 23:44           ` Larry McVoy
2020-03-23  8:49           ` Peter Pentchev
2020-03-24  9:47             ` Derek Fawcus
2020-03-25 23:25               ` Grant Taylor via TUHS
2020-03-25 23:47                 ` Richard Salz
2020-03-26  0:11                   ` Grant Taylor via TUHS
2020-03-26  0:18                     ` Richard Salz
2020-03-26  1:08                       ` Grant Taylor via TUHS
2020-03-26  2:38                         ` Dave Horsfall
2020-03-26  3:08                           ` Rob Pike
2020-03-26  3:43                             ` George Michaelson
2020-03-26  4:11                           ` Grant Taylor via TUHS
2020-03-28 11:12                           ` Peter Pentchev
2020-03-28 11:14                             ` Peter Pentchev
2020-03-28 16:03                               ` Steffen Nurpmeso
2020-03-26  1:20                       ` Tony Finch
2020-03-27 10:51                   ` Derek Fawcus
2020-03-09 23:22 ` [TUHS] First appearance of named pipes Grant Taylor via TUHS
2020-03-10  7:29   ` arnold
2020-03-11  2:47     ` Grant Taylor via TUHS [this message]
2020-03-11  7:02       ` arnold
2020-03-10 13:49   ` Chet Ramey
2020-03-10 20:26     ` Dave Horsfall
2020-03-10 20:37       ` Chet Ramey
2020-03-11  2:51       ` Grant Taylor via TUHS
  -- strict thread matches above, loose matches on Subject: below --
2020-03-08 21:42 Paul Ruizendaal
2020-03-08 22:04 ` Jon Steinhart
2020-03-06 20:41 Paul Ruizendaal
2020-03-06 21:06 ` Clem Cole
2020-03-06 21:10   ` Clem Cole
2020-03-07  5:08     ` Heinz Lycklama

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=4fb5b7ab-03a4-df64-d25b-8be587b6a17b@spamtrap.tnetconsulting.net \
    --to=tuhs@minnie.tuhs.org \
    --cc=gtaylor@tnetconsulting.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).