begin quoting Lan Barnes as of Tue, Apr 10, 2007 at 12:31:47PM -0700: > [snip] > Hmm ... centuries ago I took a C/Unix programming course in which we > simulated (actually, recreated) the pipe function by overwriting the stdin > of a process with the stdout of another. Are you saying there might be > languages based on this?
That's pretty much how you implement pipes in a shell. Create a pipe, fork, fork, close stdin, dup to stdin, close stdout, dup to stdout, exec, exec. > Because I would think that any scripting language (like Tcl) that allows > new commands to be added using C could easily develop a couple of commands > that would do that (and undo it afterward). You pretty much need to spawn off processes to do this, or write your command to read/write from/to streams that you passed in to the function. > But because I have no feel for > how it would be used in programming (other than what could be done by > opening a pipe file or calling a pipe in a shell), I'd probably botch it. Java makes it easy to compose streams -- you can basically wrap a stream with another stream that transforms it in some way, and then chain together the transformations. Smalltalk is even more flexible (you iterate through a list by reading from it as if it were a stream). I'm sure that many other languages have similiar features. > Or am I just not getting this? I am not sure I'm getting it either. I await enlightenment. -- Dangerous Phrase #7: "Piece of cake." Stewart Stremler -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg
