3 ms·
And how does that work in a shell pipeline? Stdin comes from one process and stdout goes to another. This is easy if stdin and stdout can be separate places.
by jstanley 8y ago
And how does that work in a shell pipeline? Stdin comes from one process and stdout goes to another. This is easy if stdin and stdout can be separate places.
- gizmo686 8y agoThere is no real reason why the read call and write call on a filedescriptor need to go to the same place. To make this work well, I think you would need the concept of a pipeline at the file level. Eg, if process A has a pipeline file pipeA, and process B has a pipeline file pipeB, you would need some form of linkPipe(pipeA,pipeB) syscall that causes in in buffer of pipeB to be the same as the outbuffer of pipeA. Granted, this breaks the general model of a file representing a single block of bytes that both reads and writes operate on, but that model is already gone in UNIX (eg, the in and out buffer for sockets are seperate). I'm not convinced this is actually a good idea, but seems doable.
- inetknght 8y agoI think it's rather short-sighted to think of a shell pipeline as unidirectional. Imagine if you want to be able to provide random seeking capability to your input source but the seek destinations determined by the output consumer? That's rather difficult to do with a unidirectional pipeline.