My explanations are quite long but my Enlish is not
so good, please understand me.
Some programs, for example gcc for win32 (cygnus gcc),
doesn't work for '>'.
You can redirect standard input or output or other
file handles by using dup2.
For example, following code redirects standard output
to a file handle 'fd'.
dup2( fd, 1 );
If you executes a program after above is processed,
its output is stored to the file. Another tip is
that, when you develop your program for Windows GUI
platform, you need to consider this platform doesn't
have standard output so above method doesn't directly
work. The way(trick) to solve this problem is:
1. make a win32 console mode program to capture a
program output using dup2 by executing a requested
program.
2. Launch the program you made for 1 in the GUI
mode application.
So the GUI application executes the console mode
program you made and the console mode program
actually executes the program you wanted to execute
and captures its output. Needed informations are
transferred using program arguments and program
can be waited by wait(unix) or WaitForSingleObject(win32).
I think this method is used in UltraEditor for Win32.
To capture the output of a program interactively,
you need to use pipe. Refer to documents for Unix
pipes or Win32 pipe programming. It is more complex
than dup2.
Hee S. Chung
heesc@netian.com