Mail Archives: djgpp/1995/07/25/23:49:49
Look, I've heard lots of people whining about how to get stderr
redirected. Typically people have said "Set go32=2r1", but without go32,
this doesn't work so great. So, give this a shot. It's not particularly
elegant or happy or anything, but it (I hope) works. :)
#include <stdio.h>
#include <process.h>
#include <dos.h>
#define LOTS 1
#define MORE 2
void main(int argc, char **argv)
{
if (argc < 3){
printf("Usage: ThisFile.Exe <file> <commandline>\n");
exit(LOTS);
}
if ((freopen(argv[1],"wb",stderr) == NULL))
{
printf("Stupid filename.\n");
exit(MORE);
}
execvp(P_WAIT, argv[2], &argv[3]);
/* spawnvp(P_WAIT, argv[2], &argv[3]); */
/* Spawn fragments memory quite nicely. Try it sometime. */
}
(I know this is very stable; I managed to succesfully redirect the error
messages from one compile.. all 947 error messages. (You'll hear from me
on this list again.. ))
/***************************************************************
*** Jesse Morris *** enrico AT max DOT tiac DOT net *** jmorris AT ace DOT com ***
***************** Cuthalion / Sliced Bread *******************/
- Raw text -