On 3/10/20 1:29 AM, arnold(a)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