Mail Archives: djgpp/1994/12/19/17:03:31
> I've never seen them in source form
A while ago I have sent a little program to this list which redirects
stderr to stdin, but it somehow didn't made it. As the question seems
to be arise again, I give it another try. So here is the program:
**************** ERR2STD.C ********** CUT HERE *****************
#include <stdio.h>
#include <io.h>
#include <process.h>
main(int argc, char **argv)
{
int nStdErr;
if(argc < 2)
{
fprintf(stderr, "Error output redirection program for DOS\n"
" Usage: %s <executable name> [<parameters>]\n", argv[0
exit(1);
}
dup2(fileno(stdout), fileno(stderr));
argc--;
argv++;
execvp(argv[0], argv);
perror("");
return 0;
}
************** CUT TILL HERE ************************
This program was compiled by Turbo C++/Borland C++ and was tested
to run correctly with GCC. (OK Do not tell me that I have an unused
variable nStdErr! FIrst I put some test printout in the program and
when I took them out I simply forgot to delete that line...)
I hope this helps.
Andras
- Raw text -