delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/07/25/23:49:49

Date: Tue, 25 Jul 1995 22:31:24 -0400 (EDT)
From: Cuthalion / Sliced Bread <enrico AT max DOT tiac DOT net>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Redirecting standard error and stuff.

	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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019