kenmo wrote:Bitblazer is 100% right, when you use the "|" character in a console it's actually running multiple commands and connecting them together.
Because this is really essential in understanding, i made some amateurish graphics and will attempt a simplified explanation.
When a shell does when it launches a commandline executable (among other things) is to create a process envorinment. Among loading of data, resolving adresses and bindings (DLL's, SO's), it also creates a file descriptor table in each process. The first descriptors are reserved and connected to IO pathes the command processor handles (for a terminal window, that would usually be keyboard input and console text output). Remember that this design was invented many decades ago for text processing and not GUI's.
The first descriptors are reserved and called STDIN, STDOUT and STDERR. Their numbers internally are 0, 1 and 2. In many command processors you can manually re-assign them by their internal number ( cat textfile.txt 2> errors.txt" would make a shell send all STDERR messages into the file "errors.txt".
For one process executed from a commandline it looks like this
If you use a pipe symbol between 2 commands, the shell processor will spawn two processes and manipulate their IO tables like this:
With the right tools or if you actually look inside the source of different shell processors, you can watch this whole process nicely. For unix use something like trace/strace/dtrace and for windows i suggest looking into
WinAPIOverride
kenmo wrote:RunProgram() has a #PB_Program_Connect flag for exactly this purpose but I tried and I can't get it working. I don't think it's a commonly used feature and I can't find any examples on the forum.
I grepped my sources but i actually never used the flag anywhere and i wrote quite a few console programs
