Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Given I was asked the question without having enough Linux knowledge to answer, I try it here.
Is it possible to use a re-direct ">" to send standard output to a device in /dev, while also using a "<" to have incoming standard input from the same device arrive in a file, or maybe program controlled buffer, without needing to install any special kernel modules or devices?
We already know that if we use the "|" pipe command, the outgoing stream is immediately returned to the input stream. For us, the need is to have some sort of node, hopefully a standard device like /dev/TTYn, which can take standard output, and also accept external event input directed into a different buffer.
I don't understand the question. You want some device that will read data from stdin and do what with it? You want output from this device to then go to a file, but what output? What is this device doing? What are you sending it and what are you expecting to get out of it?
The ">" redirect operator transfers one of the process's standard inputs or outputs to/from an external file. Only one process exists.
The "|" pipe operator actually creates two simultaneous processes, and creates a FIFO-queue (a "pipe") which connects the STDOUT of the left-hand process to the STDIN of the right-hand process. Two processes exist, running simultaneously. Eventually the "writer" finishes writing and closes the pipe. The "reader," upon consuming the rest of the information in the pipe, is notified that the pipe has been closed and terminates also.
Pipes provide automatic synchronization and buffering: if the writer writes "too much" and the pipe becomes full, it is suspended until the reader consumes some of it. Likewise, if the reader finds that, at the moment, there's no information there, it is suspended until the writer writes (or, closes the pipe).
Both of these are examples of "redirecting the STDIN, STDOUT, and STDERR streams," but one uses a disk-file while the other uses a pipe.
Also note that, to the user of a pipe, a pipe works just like a (non-seek()-able) disk file.
It really is "quite elegant."
Last edited by sundialsvcs; 08-10-2016 at 09:02 AM.
I get it that the ">" redirect always interfaces to a file, which is not what we need.
Clearly the pipe operator is the more useful in this case.
The original sketch showed a program using two FIFO buffers, one for output, another for input, both going to a node which was the interface to the outside world, likely a UDP transfer.
I think the issue was that if an outgoing "|" pipe transfer happened to the node (a device like TTYn ??), then the data was immediately sent back up the other FIFO.
Given there is "automatic" FIFO property inherent in the "|" pipe operator, we may now know enough. Certainly I have learned something new. My colleague is much more skilled at programming than I am, and I have made him aware of this thread.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.